Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

What operator can be used in the conditional evaluation of an if statement to so that both Boolean expressions must be true for the compound

What operator can be used in the conditional evaluation of an if statement to so that both Boolean expressions must be true for the compound expression to be true?



Conversely what operator is used so that either Boolean expression can be true for the compound expression to be true?
 

When is the short-circuit evaluation performed for an or statement?

What are the only possible values available for a Boolean variable?

What operator can be used to reverse the value of a Boolean expression?

Writing iffy statements

Write the python code for the following situations. I have highlighted variable names in bold.

Print "bad weather" if temperature is greater than 100 or less than 0.
 
Print "Great weather" if temperature is between 65 and 75.
 
Print "Class Cancelled" if severe_weather is True and class_format is "On Campus"

Print "Class as Scheduled" if class_format is not equal to "On Campus" or severe_weather is False.
 
Print True if variable x is greater than y and less than z. Otherwise print False.
 
Boolean Variables

For each of the questions in this section, read the code and indicate whether True or False is printed.

What is printed for the code below:
a = True

b = False

c = True

d = a or b or c

print(d)

What is printed for the code below:
a = True

b = True

c = False

d = a and b and c

print(d)

What is printed for the code below:
a = True

b = True

c = True

d = a and b and c

print(d)


What is printed for the code below:
a = True

b = True

c = False

d = a and b and c

print(d)


What is printed for the code below:
a = True

b = not a

print(b)

 
What is printed for the code below:
a = False

b = not a

print(b)

Programming Exercise

For the following exercise, you will be writing a program to calculate rewards for a book club. Serendipity booksellers has a book club that awards points t its customers based on the number of books purchased each month. The points are awarded as follows:

If a customer purchases 0 books, they earn 0 points.
If they purchase 2 books, they earn 5 points.
If they purchase 4 books, they earn 15 points.
If they purchase 6 books, they earn 30 points.
If they purchase 8 or more books, they earn 60 points.
 

The program should ask the user to enter the number of books that they have purchased this month and then displays the number of points awarded.
It should look something like this when run:

Copy the python code in the section below.

Python Code


Take a screenshot of tests for each point range.

Step by Step Solution

3.34 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

python code Ask the user to enter the number of books purchased numbooks intinputEnter the number of books purchased this month Calculate points based ... blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Digital Logic With Verilog Design

Authors: Stephen Brown, Zvonko Vranesic

3rd Edition

978-0073380544, 0073380547

More Books

Students explore these related Programming questions