Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Hangman Game - Programming Questions

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a IF statement a type of?

a)

Iteration

b)

Sequence

c)

Selection

2.

What is a WHILE loop a type of?

a)

Iteration

b)

Sequence

c)

Selection

3.

What does this code do?

x = random.randint(0,4)

a)

x is set to 0,4

b)

x is set to a random number between 0 and 4

c)

this code does not work

d)

x is set to 0, then 1, then 2, then 3, then 4

4.

If you wanted to use anything such as time.sleep() from another library, what must you first do?

a)

import the library

b)

use the function from the library

c)

create a new function

5.

How do you get the user to type their name in?

a)

name = "Tom"

b)

name = ("What is your name?")

c)

print("What is your name?")

d)

name = input("What is your name?")

6.

How do you find out how many letters are in a variable called word?

a)

wordLength = length(word)

b)

wordLength = len(word)

c)

wordLength = 5

7.

Which line correctly displays a users name?

a)

name = input("What is your name?")

print("Welcome", name)

b)

name = ("What is your name?")

print("Welcome", name)

c)

name = input("What is your name?")

print("Welcome name")

d)

name = input("What is your name?")

print("Welcome" name)

8.

How do you check if a user has entered more than one letter?

a)

if letter > 1:

print("You have entered more than one letter")

b)

if letter < 1:

print("You have entered more than one letter")

c)

if letter = 1:

print("You have entered more than one letter")

9.

How do we update a variable? For example by increasing somebody's age by 1 year.

a)

age = age + 1

b)

age = newAge

c)

age = newAge + 1

10.

How do we check if two variables are the same?

a)

If name == name:

print ("You have the same name")

b)

If name = name:

print("You have the same name")

c)

if name equals name:

print("You have the same name")

11.

How do you make all the contents of a variable lowercase?

a)

name = lowercase()

b)

name = name.lower()

c)

name = name.lowercase()

d)

name = name.upper()

12.

How do you check if a variable is only letters and not numbers?

a)

if name.isNumber:

print("Name contains numbers")

b)

if name.isLetters:

print("Name contains letters")

c)

if name.isAlpha:

print("Name contains letters")

d)

if name.isPunt:

print("Name contains punctuation")

13.

What does this function do?

a)

Nothing

b)

outputs "my_function"

c)

outputs "Hello from a function"

14.

What does this function do?

a)

outputs "fname"

b)

outputs "fname Refsnes"

c)

outputs "Emil Refsnes"

d)

Nothing

15.

How would you call this function to make it work?

a)

X()

b)

Hello()

c)

testing()

d)

def()