WorksheetsBCHS - Y8 Python
Total questions: 25
Worksheet time: 14mins
What will be the output of the Python code below when run?
print("Hello there!")
Hello there!
print("Hello there!")
Hello there
"Hello there!"
What happens if you remove the quotes around "there" in the code?
print("Hello there")
The code will not run because "there" will be treated as an undefined variable.
The code will run without any issues.
The output will include the word "there" without quotes.
The code will print a syntax error message.
What is the output of the code if you change the word 'there' to 'you'?
print("Hello there")
Hello you
Hello there
Hello
An error occurs
What effect does changing the 'p' in 'print' to a capital 'P' have on the code?
The code will run without any issues.
The code will not run because Python is case-sensitive.
The output will be capitalized.
The output will change to a different font.
What is the primary purpose of the Python program described below?
To calculate mathematical equations
To print the user's name on the screen
To draw a picture
To play a video
What will be the output of the Python code if the user inputs the name "John"?
Hello John
Hello + John
What is your name? John
John Hello
What does the Python function 'input()' do in the code?
Displays a message
Pauses the program and waits for the user to enter some text
Adds "Hello" to the user's name
Prints the user's name on the screen
What happens if you change 'name =' to 'word =' in this Python program?
The script will stop executing
The variable 'word' will be used instead of 'name'
The script will output an error message
Nothing changes in the script
What is the effect of putting quotes around a variable name in the print statement in Python?
The variable's value is printed
The name of the variable is printed
An error occurs
The print statement is ignored
How can you modify a Python script to ask for and include both the user's first name and surname in the output?
Use separate input() functions for each name
Combine the names into one input()
Use a list to store names
It's not possible to modify
What is a correct way to greet a user by name using Python?
print("Hello" + name)
print("Hello name")
Print("Hello" name)
print("Hello", "name")
Which Python script correctly stores a user's name and age and then displays them?
name = input(); age = input(); print(name, age)
name, age = input(); print(name + age)
name = input(); print(name); age = input(); print(age)
input(name); input(age); print(name + age)
What will be the output of the following Python code if the inputs are 3 and 5?
A) 8
B) 35
C) 15
D) Error
What is the purpose of the 'input' function in the provided Python code?
A) To display a message to the user
B) To assign a value to a variable
C) To take user input as a string
D) To perform arithmetic operations
What happens if you enclose both of the input statements with the int() function in Python?
It converts the inputs to integers before any operations.
It causes a syntax error.
It ignores the input values.
It outputs the inputs as strings.
What is the primary function of the int() function in Python?
It converts a string or a number to an integer.
It checks if the input is an integer.
It multiplies two integers.
It divides two integers.
What modification should be made to a Python code to multiply two inputted values instead of adding them?
Replace the '+' operator with the '*' operator in the code.
Change the int() function to str().
Remove any mathematical operators.
Enclose the operation in a print() function.
What operation does the program perform that takes two inputs and displays this result?
Multiplication
Division
Addition
Subtraction
What is the first step in writing a program to calculate the volume of water required to fill a pool?
Output the volume
Input the depth of the pool
Input the length, width, and depth of the pool
Calculate the area using a formula
What will the Python code output if the user inputs "Good"?
Sorry you're unhappy
Great to hear it!
No output
Error
What will the Python code output if the user inputs any string other than "Good"?
Great to hear it!
Sorry you're unhappy
No output
Error
What should happen when a user modifies a code to ask for a number and enters '1'?
The program should terminate.
The program should ask for another input.
The program should respond with a specific message.
The program should display an error.
What is expected to occur if the last two lines of a given code are removed?
The code will not compile.
The code will run indefinitely.
The code will execute without any output.
The code will execute the remaining commands normally.
Match the following types of data used in Python programming
String
hello
Integer
300
Boolean
true
Array
[1, 2, 3]
Float
2.55
Complete the code below
age = (a) ("Please enter your age")
