Hi,
I have recently purchased a Raspberry Pi with the aim to learn some programming.
I have previously completed the "Hello World" tutorial and thought i could progress on unfortunately I don't have any knowledge with this to i am reaching out for some help.
Currently I have:
Print ("Hello what's your name")
name = input ("name: ")
I then want to print code to pull through.
Print ("Hello its nice to meet you <name>") but i don't know the code to pull the name previously added to show here.
any ideas?
Russ
-
- Posts: 2
- Joined: Sat Apr 19, 2014 1:18 pm
- Location: Essex
Re: basic code for a noob
You're using Python 3?
Try this :
it should work, but not the most elegant.
Try this :
Code: Select all
Print ("Hello what's your name")
name = input ("name: ")
Print ("Hello its nice to meet you " + str(name))
Re: basic code for a noob
"Hello World" is a great start, but you will need to follow some more tutorials if you are going to progress. The syntax of any programming language has to be exact to work, and you will be very slow if you try to do it by trial and error. I suggest you Google <Python Tutorial>, or search YouTube, or buy a basic book. I used all three to start me off, but I have programmed before (albeit 40 years ago).
Select the one you feel most comfortable with - just be sure that it is Python3. (I got very confused when I first started as I ended up with a mix of the two versions which will never work).
Hope this helps,
Select the one you feel most comfortable with - just be sure that it is Python3. (I got very confused when I first started as I ended up with a mix of the two versions which will never work).
Hope this helps,
Sue B
Raspberry Pi Noobie!
Raspberry Pi Noobie!
Re: basic code for a noob
There are a lot of good Pi-based tutorials in the MagPi online magazine (free download) at http://www.themagpi.com/
Re: basic code for a noob
good luck with learning python (and coding generally). On your specific question:
the old system (which python still supports) was based on the C style printf system where you could put %s type placeholders in a string and then follow it with the variable(s) you wanted to insert so in your case
Lots of people still use this method but the 'modern' way of doing this is using curly brackets and as this style is now pretty widely adopted you are best to go with that IMHO!
https://docs.python.org/2/library/strin ... formatspec
PS by widely adopted I mean in the wider world of web programming search for liquid templates as used in things like jekyll, django, flask, rails etc
the old system (which python still supports) was based on the C style printf system where you could put %s type placeholders in a string and then follow it with the variable(s) you wanted to insert so in your case
Code: Select all
print ('Hello its nice to meet you %s' % name)
Code: Select all
print ('Hello its nice to meet you {}'.format(name))
PS by widely adopted I mean in the wider world of web programming search for liquid templates as used in things like jekyll, django, flask, rails etc
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
Re: basic code for a noob
You can download Minecraft Pi Edition and hack it using Python. That is a fun way of learning Python.
If you don´t know how to start with Minecraft Pi Edition just search for "hacking minecraft pi edition" and a result uploaded by Tinkernut will show up. That video is a good tutorial.
Good luck!
If you don´t know how to start with Minecraft Pi Edition just search for "hacking minecraft pi edition" and a result uploaded by Tinkernut will show up. That video is a good tutorial.
Good luck!
I'm a swedish viking with big beard, I like to eat raspberry pi.