Search Header Logo

Introduction to Python Programming

Authored by Andrew Powell

Computers

9th Grade

Used 14+ times

Introduction to Python Programming
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the following Python code do? if user == "Elizabeth": print("Good morning Your Majesty") else: print("Hello", user)

Checks if the user is Elizabeth and prints a personalized greeting.

Prints "Hello" followed by the user's name for all inputs.

Compares if two variables are equal.

Always prints "Good morning Your Majesty."

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which operator checks if two values are not equal in Python?

==

!=

<

>=

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output if the input is 13? lucky = 13 print("Guess my number:") guess = int(input()) if guess == lucky: print("Amazing, you guessed it") else: print("Sorry, it's not", guess)

"Amazing, you guessed it"

"Sorry, it's not 13"

"My lucky number is 13"

No output

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of importing the randint function from the random module?

To allow the program to compare two numbers.

To generate random integers within a specified range.

To check if a condition is true or false.

To handle user input more effectively.

5.

FILL IN THE BLANK QUESTION

30 sec • 1 pt

Fill in the blank to complete the code for rolling a dice: from random import randint diceroll = _______ print("You rolled a", diceroll)

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output if diceroll equals 4? from random import randint diceroll = 4 if diceroll > 3: print(diceroll, "is a large roll") else: print(diceroll, "is a small roll")

"4 is a large roll"

"4 is a small roll"

No output

"Yet you rolled a 4"

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

True or False: The output of the following code will always be the same. from random import randint diceroll = randint(1,6) print("You rolled a", diceroll)

True

False

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?