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
A _______ is conducted to determine the adequacy of system controls, ensure compliance with established security policy and proc
kow [346]

Answer:

security audit

Explanation:

7 0
3 years ago
What is the formula equivalent to the function =SUM(B1:B5)? A. =B1+B5 B. =$B$1+$B$5 C. =B1+B2+B3+B4+B5 D. =$B$1+$B$2+$B$3+$B$4+$
Contact [7]

Given the options, I would choose Option C. =B1+B2+B3+B4+B5.

5 0
3 years ago
When a formula contains the address of a cell, it is called a(n)
Shalnov [3]
When a formula contains the address of a cell, it is called a c<span>ell reference.

hope this helps!</span>
8 0
3 years ago
What does this mean, i am so confused- Explain the importance of identifying the purpose/use for pre-production documents
irina1246 [14]

Answer: These are mostly used in interior design, fashion design, and advertising. they are often used to generate ideas for a client to meet their approval before making the final product. It can help in terms of planning because it could be used to create a design or a theme.

Explanation: yw

4 0
2 years ago
Type the correct answer in the box. Spell all words correctly. Complete the sentence based on the role education plays to help y
CaHeK987 [17]

Answer:

what do i do??

Explanation:

8 0
2 years ago
Other questions:
  • When a relationship is established between two or more arrays by using the same subscript to relate entries between the arrays,
    14·2 answers
  • What do you think about the use the top song on a video you are creating
    8·2 answers
  • ______________ is only one of the marketing mix tools that acompany uses to achieve its marketing objectives.
    7·1 answer
  • The term Electronic Privacy Information Center (EPIC) refers to a form of the digital subscriber line technology, which enables
    6·1 answer
  • Yall like portal 1 or 2
    8·1 answer
  • Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of text files at startup. The fi
    15·1 answer
  • Robert gets home from school at 3 p.M. His mom has to leave for her shift at work at 3:15 and she wants him to watch his baby br
    9·1 answer
  • Write a program that prompts the user to enter a grade, which is aninteger in the range of 0 - 100. Using if statements, have th
    11·1 answer
  • Who is this person?<br><br><br> Kaneppeleqw. I see them everywhere. Are they a bot? Are they human?
    8·1 answer
  • Accessibility is the degree to which a product or service is readily available and usable by _____.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!