Search Header Logo

Discovery Python

Authored by Ayman Marzouk

Computers

University

Used 6+ times

Discovery Python
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the following shell command do?

echo 'print("Hello, World!")'

  • Executes the Python script hello_world.py.

Saves the text print("Hello, World!") to a file.

Prints the text print("Hello, World!") in the terminal.

Converts the text to uppercase.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How would you run a Python script named age.py from the terminal?

run age.py

python3 age.py

Both b and c

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will this Python script print?

age = 25

print(f"In 42 years, you will be {age + 42}")

In 42 years, you will be 42

In 42 years, you will be 67

In 42 years, you will be 25

Throws a syntax error.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following Python snippet do?

number = float(input("Enter a number: "))

if number == 0:

print("The number is zero.")

else:

print("The number is non-zero.")

Always prints "The number is zero."

Always prints "The number is non-zero."

Checks if the input is zero or non-zero and prints the respective message.

Raises an error if the input is not a valid number.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of this Python code?

word = "Python"

print(word.upper())

  • PYTHON

python

Throws an error.

Python

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will this Python code output?

number = 5

while number < 10:

print(number)

number += 2

5 7 9

5 6 7 8 9

5 7 9 11

Infinite loop.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does this Python snippet do?

password = "letmein"

entered_password = input("Enter your password: ")

if entered_password == password:

print("Access Granted")

else:

print("Access Denied")

Compares the entered password with password and prints the respective message.

Throws an error because input is not defined.

Always prints "Access Granted."

Always prints "Access Denied."

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?

Discover more resources for Computers