I am just starting out in the world of python. I have basic knowledge of coding in vb.net and java. I understand logic, but struggle with syntax.
I am trying to play around with my first program and struggle with verification methods within the program.
- Code: Select all
# This program will take the input of a users name
# and greet them with a hello!
name = raw_input('What is your name?\n')
print "Hello, " + name
response = raw_input('How are you today?\n')
print "I am glad that you are " + response
favnum = raw_input('What is your favorite number?\n')
print "Do you know what " + favnum + " times 5 is?"
mathinput = int(favnum) * int(5)
I am looking for what I believe is going to be if, then, else structures. I want to verify that when a user inputs a "name" when asked that it is a string, not an numeric value.
I also want to verify that when they enter their favorite number it is a int, not a float. This isnt complete yet, but essentially I would want the user to enter their favorite number, then the question be asked what that number is * 5 then allow for input, then do a if, then, else statement again to verify their answer is correct.
Can someone give me some guidance?