18.3k views
6 votes
3.4 lesson practice quiz edhesive

2 Answers

9 votes

It is to be noted that the output of the above given code will be "ONE" (Option A)

The % operator is the modulo operator, and 9 % 2 gives the remainder when 9 is divided by 2, which is 1.

Therefore, the condition (x == 1) is true, and the code block under the if statement is executed, printing "ONE."

The modulo operator (%) calculates the remainder when one number is divided by another. For example, 9 % 2 equals 1 because 9 divided by 2 equals 4 with a remainder of 1.

Full Question:

Although part of your question is missing, you might be referring to this full question:

What is the output?

x = 9 % 2

if (x == 1):

print ("ONE")

else:

print ("TWO")


ONE

one

One

User Perica Zivkovic
by
5.8k points
5 votes

3.4 lesson practice quiz edhesive :

Write a program to check if user inputs "yellow"

Answer:

In Python:

col = input("Enter Color: ")

if col == "yellow":

print("True")

else:

print("False")

Step-by-step explanation:

This prompts the user for color

col = input("Enter Color: ")

This checks if color is yellow

if col == "yellow":

If true, this prints true

print("True")

If otherwise, this prints false

else:

print("False")

User Ben Sheldon
by
5.6k points