1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
murzikaleks [220]
3 years ago
12

Write an expression that will print "in high school" if the value of user_grade is between 9 and 12 (inclusive). Sample output w

ith input: 10 in high school

Computers and Technology
1 answer:
Strike441 [17]3 years ago
7 0

Answer:

Here is the expression:

user_grade = 10 #assigns 10 to the value of user_grade

if user_grade >=9 and user_grade <=12:  #checks if the user_grade is between 9 and 12 inclusive

   print('in high school')  # prints in high school if above condition is true

else:  #if user_grade is not between 9 and 12 inclusive

   print('not in high school') # prints not in high school if user_grade is not between 9 and 12 inclusive

This can also be written as:

user_grade = 10  # assigns 10 to user_grade

if 9<=user_grade<=12:  #if statement checks if user_grade is between 9 and 12 inclusive

   print('in high school')  #displays this message when above if condition is true

else:  #when above if condition evaluates to false

   print('not in high school')#displays this message

Explanation:

If you want to take the user_grade from user as input then:

user_grade = int(input("Enter user grade: "))

if user_grade >=9 and user_grade <=12:

   print('in high school')

else:

   print('not in high school')

The expression

if user_grade >=9 and user_grade <=12:  

contains an if statement that checks a condition that can either evaluate to true or false. So the if condition above checks if the value of user_grade is between 9 and 12 inclusive.

Here the relational operator >= is used to determine that user_grade is greater than or equals to 9. relational operator <= is used to determine that user_grade is less than or equals to 12.

The logical operator and is used so both user_grade >=9 and user_grade <=12 should hold true for the if condition to evaluate to true. This means the user_grade should be between 9 and 12 (inclusive).

For example is user_grade = 10 then this condition evaluates to true as 10 is between 9 and 12 (inclusive). Hence the message: in high school is displayed on output screen.

But if user_grade= 13 then this condition evaluates to false because 13 is greater than 12. Hence the message: not in high school is displayed on output screen.

If user_grade = 8 then this condition evaluates to false because 8 is less than 9. Notice here that 8 is less than 12 so one part of the condition is true i.e. user_grade <=12 but we are using logical operator and so both the parts/expressions of the if condition should evaluate to true. This is why this condition evaluates to false. Hence the message: not in high school is displayed on output screen.

The screenshot of program and its output is attached.

You might be interested in
Write a program with a method computeCommission which takes a double that is the salesAmount and returns the commissions for sal
miv72 [106K]

Answer:

Explanation:

def computeCommission(salesAmount):

   commission=0

   if salesAmount <= 50000:

       commission = 5000*0.08 + (salesAmount-5000)*0.1

   elif salesAmount > 50000:

       commission = 5000*0.09 + (salesAmount-5000)*0.12

   return commission

print("commission for 45000 : "+str(computeCommission(45000)))

print("commission for 54000 : "+str(computeCommission(54000)))

4 0
3 years ago
What does the merge &amp; center button in the alignment group on the home tab do?
e-lub [12.9K]
A merge and center does this;
if you have created a table,it just centers a sentance
6 0
3 years ago
The security administrator for Corp.com wants to provide wireless access for employees as well as guests. Multiple wireless acce
Reil [10]

SSIDs should separate each network.

(d)SSIDs

<u>Explanation:</u>

In an organization or corporation office, End user is office staff he or she can access to different SSIDS, Where restrictions access can be configured at firewall level.

So if any guest he or she will ask to connect different SSIDS so that guest will not enter to internal networks. Where guest is connected to only on restricted area network such as internet etc.  Due to this if guest pc is attacked by virus it can prevented by attacking the same to internal office network.

7 0
3 years ago
Describe how electrons move between atoms to create electricity.
pentagon [3]
Applying potential difference to a conductor, by potential force, free electrons gain energy and move from low to high potential. Thus, electrons move from one atom to another.
3 0
3 years ago
Read 2 more answers
Pleasee help meeeeeeeeee I’m stuckk!!!!
Anit [1.1K]

Answer: Charles Babbage

4 0
3 years ago
Read 2 more answers
Other questions:
  • All of the following statements correctly describe an advantage or disadvantage associated with the use of Monte Carlo Analysis
    9·1 answer
  • Program 4: But I haven’t taken Calculus yet! OK – we admit, this one might look nasty, but read on because it’s not that bad. On
    11·1 answer
  • Write a C++ program that allows the user to enter double values. Display one of two messages: "The first number you entered is l
    9·1 answer
  • Which of the following involves writing hidden messages so that only the sender and intended recipient know a message exists? St
    5·1 answer
  • I can't find the errors! Could anyone help me please?!
    5·1 answer
  • To open a Google Doc in another software application, the user must first download it. True or false?
    12·2 answers
  • Which of the following screen elements is a horizontal bar that displays at the
    8·1 answer
  • 15. Virus cannot infect files that are saved in i. USB ii. CD-ROMs iii. Memory card iv. All of them​
    14·2 answers
  • A leading global vendor Of computer software hardware for computer mobile and gaming systems and cloud services it's corporate h
    14·1 answer
  • Which of the following is an example of machine learning?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!