Python Forum
Help with Quiz - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Help with Quiz (/thread-3437.html)



Help with Quiz - Learning2teach - May-23-2017

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")



RE: Help with Quiz - Ofnuts - May-23-2017

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.