Python Forum

Full Version: Help with Quiz
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello I am trying to create a basic quiz of 5 questions .
I am really new to programming and so any help with be fantastic .
The code needs to be very basic. Can someone please correct my code . I need the ans1 to be "int"
Many thanks

score= 0#score start with zero
name = input("Enter your name:    ")
ans1= input(int("Q1. What is 3*3 ?")
if ans1== 9:
            print("Correct")
            score=score+1
else:
        print("Incorrect")
int(some_string) returns the integer value of some_string (if it can be decoded to an integer):

Output:
>>> type('00012') <type 'str'> >>> int('00012') 12 >>> type(int('00012')) <type 'int'>

What happens when the string is not all digits will be addressed when you come to it.