S4: RECAP UNTIL TESTING

S4: RECAP UNTIL TESTING

11th Grade

11 Qs

quiz-placeholder

Similar activities

Repaso de Python

Repaso de Python

5th Grade - Professional Development

15 Qs

Yr 9 & Yr 10 recap

Yr 9 & Yr 10 recap

9th - 11th Grade

10 Qs

Podstawy pythona

Podstawy pythona

7th - 12th Grade

8 Qs

XI-MIPA 1 Belajar Python with Progate sd variable.com

XI-MIPA 1 Belajar Python with Progate sd variable.com

10th - 11th Grade

10 Qs

Python - тест

Python - тест

1st - 12th Grade

15 Qs

Java Script Quiz

Java Script Quiz

9th - 12th Grade

15 Qs

Python - 01

Python - 01

9th - 12th Grade

10 Qs

Python Циклы и Условные операторы.

Python Циклы и Условные операторы.

6th - 11th Grade

13 Qs

S4: RECAP UNTIL TESTING

S4: RECAP UNTIL TESTING

Assessment

Quiz

Computers

11th Grade

Medium

Created by

Kieran Kyle

Used 1+ times

FREE Resource

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?

x = 10

if x > 5:

print("Greater")

else:

print("Smaller")

Greater

Smaller

Error

No Output

Answer explanation

The if statement checks if x is greater than 5. Since x is 10, the condition is True, and "Greater" is printed.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the final value of sum after this code is executed?

num = 0

for i in range(5):

num = num + i

print(num)

5

10

15

20

Answer explanation

The loop iterates over a range of 5 numbers from 0 to 4. The sum of these numbers (0+1+2+3+4) is 10

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the list my_list = ["apple", "banana", "cherry"]


What does print(len(my_list)) return?

3

6

15

Error

Answer explanation

The len() function returns the number of items in an object. Since my_list contains three items, the result is 3.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be printed by the following code snippet?

fruits = ["apple", "banana", "cherry"]

print(fruits[1])

apple

banana

cherry

IndexError

Answer explanation

Arrays in Python are zero-indexed, so fruits[1] refers to the second element in the list, which is "banana".

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the following code do?

user_input = 0

while user_input < 1 or user_input > 10:

user_input = int(input("Enter a number between 1 and 10: "))

Repeats until a number less than 1 is entered.

Repeats until a number greater than 10 is entered.

Repeats until a number between 1 and 10 is entered.

Causes an infinite loop.

Answer explanation

The code keeps asking for input until the user enters a number within the range 1-10 (inclusive).

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How does the following code snippet calculate a running total?

numbers = [1, 2, 3, 4, 5]

total = 0

for index in numbers:

total = total + index

Adds the index of each element to total.

Adds the value of each element to total.

Multiplies the value of each element with total.

Subtracts the value of each element from total.

Answer explanation

The code iterates through the list numbers and adds each to the total variable, accumulating the sum of the list elements.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What kind of error will occur when the following code is executed?

for i in range(10)

print(i)

Syntax

Logic

Execution

Extreme

Answer explanation

The code is missing a colon : at the end of the for loop declaration, which is required in Python to indicate the start of the loop's body. This will result in a syntax error when the code is run.

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?

Discover more resources for Computers