Search Header Logo

Python Programming Quiz

Authored by James Dillon

Computers

10th Grade

Used 3+ times

Python Programming Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

33 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do I print 'Hello, World!' in Python?

print(Hello, World!)

echo 'Hello, World!'

print('Hello, World!')

System.out.println('Hello, World!')

printf('Hello, World!')

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will you get if you call print (str[2:10]) and str = "Dogs are absolutely amazing creatures, far superior to snakes"

"ogs are "

"gs are ab"

"Dogs are abso"

"ogs are a"

"gs are"

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following Python function to find the maximum number in a list:

def find_max(numbers):
    max_num = numbers[0]
    for num in numbers[1:]:
        if num > max_num:
            max_num = num
    return max_num

numbers = [5, 3, 8, 6, 7]
max_number = find_max(numbers)
print("The maximum number is: ", max_number)

What is the issue with this code?

The function does not correctly find the maximum number.

The print statement is outside the function.

There is no issue; the code works as intended.

The list should be sorted before finding the maximum number.

The initial max_num should be set to None.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def calculate_sum():\n if y == 5:\n return y + 5\n elif y == 10:\n return y + 10\n\nWhat are the issues with this function?

Indentation error in line 2

Incorrect use of equality operator. Use assignment operator instead.

Indentation error in line 4

Variable 'y' is not defined within the function

There are no issues with the function

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

What is the result of the operation len('hello') + 2?

Returns the sum of the length of 'hello' and 2.

Concatenates 'hello' with '2'.

Removes 2 characters from 'hello'.

Generates an error.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of executing the following code snippet?

colors = ['Red', 'Green', 'Blue', 'Yellow', 'Black']

# Attempting to access:
print(colors[5])

Yellow

Black

IndexError

Green

Red

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the following operation? value = 'data science' list_example = [10, 20, '30', -5, 'analysis'] print(len(value), len(list_example))

12 5

11 5

13 6

10 4

error

Access all questions and much more by creating a free account

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

Already have an account?