✅ 9th Grade Other: Python Coding Worksheet Quiz
🚀 Ready for the Quiz?
This is a great opportunity to test your knowledge and see what you've learned. Read the questions carefully and check the solutions!
✅ 9th Grade Other: Python Coding Worksheet Quiz
What is the correct way to print "Hello, World!" in Python?
A) Print "Hello, World!"B) print("Hello, World!")
C) echo "Hello, World!"
D) System.out.println("Hello, World!")
Which of the following is a valid way to assign the integer value 5 to a variable named x?
A) x = 5B) x == 5
C) assign x = 5
D) int x = 5
What will be the output of the following Python code?
python
a = 10
b = 3
print(a % b)
B) 1
C) 3
D) 0
How can you get input from the user and store it in a variable called name?
A) name = get_input("Enter your name: ")B) input("Enter your name: ") = name
C) name = input("Enter your name: ")
D) read(name, "Enter your name: ")
What data type would Python typically assign to the variable price in the following code?
python
price = 19.99
B) string
C) float
D) boolean
What will be printed by the following Python code?
python
city = "New York"
temp = 25
print(f"The temperature in {city} is {temp} degrees Celsius.")
B) The temperature in New York is 25 degrees Celsius.
C) The temperature in {city} is {temp} degrees Celsius.
D) Error: Undefined variables.
What is the output of this Python code?
python
x = 7
if x > 10:
print("X is large")
elif x > 5:
print("X is medium")
else:
print("X is small")
B) X is medium
C) X is small
D) No output
How many times will "Hello" be printed by the following loop?
python
for i in range(3):
print("Hello")
B) 1
C) 3
D) 4
Which of the following Python lists is correctly initialized with the numbers 1, 2, and 3?
A) my_list = (1, 2, 3)B) my_list = {1, 2, 3}
C) my_list = [1, 2, 3]
D) my_list = "1, 2, 3"
What is the correct way to define a simple function in Python named greet that takes one argument name and prints a greeting?
A) function greet(name): print(f"Hello, {name}!")B) def greet(name) { print(f"Hello, {name}!") }
C) def greet(name): print(f"Hello, {name}!")
D) define greet(name): print(f"Hello, {name}!")
What is the value of my_list[1] after the following code executes?
python
my_list = ["apple", "banana", "cherry", "date"]
B) "banana"
C) "cherry"
D) "date"
What will be the final value of count after this Python code runs?
python
count = 0
for num in range(1, 6):
if num % 2 == 0:
count += 1
print(count)
B) 2
C) 3
D) 5
Consider the following Python function:
python
def calculate_total(quantity, price):
if quantity > 10:
discount = 0.10
else:
discount = 0
total = quantity price (1 - discount)
return total
result = calculate_total(12, 5)
print(result)
What will be the output?
B) 54
C) 50
D) 48
What will be the output of the following Python code snippet?
python
numbers = [10, 20, 30, 40]
total = 0
index = 0
while index < len(numbers):
if numbers[index] > 25:
total += numbers[index]
index += 1
print(total)
B) 30
C) 70
D) 100
Scan QR Code for Answer Key & Detailed Solutions
https://www.eokultv.com/worksheet-generator/9th-grade-other-python-coding-worksheet/quizzes