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]
2 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]2 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
• What is the difference between primary storage, secondary storage, and off-line storage
sergiy2304 [10]


Primary storage refers to your RAM it is internal storage.

Secondary storage is any storage that is not the primary storage that permanently stores data. Examples are hard drive, tape disk drive, floppy disk drive  and compact disk drive. 

Off-line storage refers to any device that stores data that is not permanently attached to the computer. Example flash drives, The data remains on the storage device and can be connected to a different computer. 

3 0
3 years ago
What are the examples of shareware?
Igoryamba

Answer:

An example of shareware a compression program like Stuffit for Macs or Windows. An example of shareware is a budgeting software program that only allows you to use three categories instead of having the ability to create a full budget.

8 0
2 years ago
Read 2 more answers
The expressions in each part of an AND or OR expression use ________ evaluation; that is, they are evaluated only as much as nec
I am Lyosha [343]

Answer:

The expressions in each part of an AND or OR expression use <u>Short Circuit</u> evaluation; that is, they are evaluated only as much as necessary to determine whether the entire expression is true or false.

Explanation:

Logic operations follow different type of evaluation methods that can be short circuit or open circuit evaluation. In short circuit evaluation if first operand of the expression is true or false in OR or AND operation respectively, the result will found as true or false without checking the second operand of the expression. This is called Short Circuit Evaluation.

In OR operation, If first operand is true it means that the result of the expression is true without knowing that the other operand is true or false. In AND operation, If the first operand is False, the result will found as False without knowing that whether the 2nd operand is  true or false.

This Mechanism is called Short Circuit Evaluation.

4 0
3 years ago
What is the full form of com​
nignag [31]

The answer is:

Commercial

3 0
3 years ago
You often need to have several applications open at the same time. Which requirement is related to this need?
Musya8 [376]

Answer:

processor speed is the answer but not sure

5 0
2 years ago
Other questions:
  • Writers should avoid jargon because jargon ______. a. Takes too long to use b. Limits what ideas can be explored c. Conveys too
    12·1 answer
  • What is the seventh byte in the roller coasters file?
    12·1 answer
  • By default, windows does not display ____________________ in windows explorer.
    8·1 answer
  • _____ is a school-to-work program that provides the student with paid employment, school credit, and grades while participating.
    14·2 answers
  • A(n) ________ is a variable that receives an argument that is passed into a function. global argument scope parameter
    15·1 answer
  • What is the best temperature to set your air conditioner on?
    12·1 answer
  • Can someone tell me? I have an assignment in C++: I have to do three codes please tell me should i do them in one project or in
    12·1 answer
  • You will be creating a quiz grading program. You will compare the student's answers with the correct answers, and determine if t
    15·1 answer
  • A(n) ____ investigation tracks all elements of an attack, including how the attack began, what intermediate devices were used du
    5·1 answer
  • One way to check if a website is secure is to look for a/an<br> in the address bar.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!