WorksheetsHangman Game - Programming Questions
Total questions: 15
Worksheet time: 8mins
What is a IF statement a type of?
Iteration
Sequence
Selection
What is a WHILE loop a type of?
Iteration
Sequence
Selection
What does this code do?
x = random.randint(0,4)
x is set to 0,4
x is set to a random number between 0 and 4
this code does not work
x is set to 0, then 1, then 2, then 3, then 4
If you wanted to use anything such as time.sleep() from another library, what must you first do?
import the library
use the function from the library
create a new function
How do you get the user to type their name in?
name = "Tom"
name = ("What is your name?")
print("What is your name?")
name = input("What is your name?")
How do you find out how many letters are in a variable called word?
wordLength = length(word)
wordLength = len(word)
wordLength = 5
Which line correctly displays a users name?
name = input("What is your name?")
print("Welcome", name)
name = ("What is your name?")
print("Welcome", name)
name = input("What is your name?")
print("Welcome name")
name = input("What is your name?")
print("Welcome" name)
How do you check if a user has entered more than one letter?
if letter > 1:
print("You have entered more than one letter")
if letter < 1:
print("You have entered more than one letter")
if letter = 1:
print("You have entered more than one letter")
How do we update a variable? For example by increasing somebody's age by 1 year.
age = age + 1
age = newAge
age = newAge + 1
How do we check if two variables are the same?
If name == name:
print ("You have the same name")
If name = name:
print("You have the same name")
if name equals name:
print("You have the same name")
How do you make all the contents of a variable lowercase?
name = lowercase()
name = name.lower()
name = name.lowercase()
name = name.upper()
How do you check if a variable is only letters and not numbers?
if name.isNumber:
print("Name contains numbers")
if name.isLetters:
print("Name contains letters")
if name.isAlpha:
print("Name contains letters")
if name.isPunt:
print("Name contains punctuation")
What does this function do?
Nothing
outputs "my_function"
outputs "Hello from a function"
What does this function do?
outputs "fname"
outputs "fname Refsnes"
outputs "Emil Refsnes"
Nothing
How would you call this function to make it work?
X()
Hello()
testing()
def()
