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
Help please! Coding!
gladu [14]

Answer:

Explanation:

16

17

5 0
3 years ago
What are the steps to open the Custom AutoFilter dialog box?
uranmaximum [27]

Answer:

data, sort and filter, text filters

Explanation:

ed 2020

7 0
2 years ago
Read 2 more answers
How do you find a single number or name you want in a
Tamiku [17]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

You can find a single number or name in a large worksheet containing thousands of numbers and names using the find and replacement feature in excel.

You can use Ctrl+F keyboard shortcut for finding and replacing features. When you press Ctrl+F, a dialog will get open, using this dialog, you can find the required number or name while entering in the search text box. Then, click on the Find button, if the worksheet matches the result, give you the matched result in the yellow highlighted color.

Also, you can use Ctrl+F to replace a name or number with some other name or number.

Alternatively, you can do this using the home tab, then find the option find and select under the editing group of commands.

8 0
3 years ago
If she presses the left arrow , what will happened
Harman [31]
The keyboard will move
4 0
3 years ago
The mouse and keyboard are also sometimes called
likoan [24]
Hi!

The mouse and the keyboard are <em>input devices. </em>By using them, we can input data which will give us a (hopefully) desired output!

For example...

Just by using my keyboard to type, I'm inputting data in the form of ASCII characters and symbols.

By using my mouse to click on an area so I can move this sentence on a new line, I had to input a request to do such!

Hopefully, this helps! =)
7 0
3 years ago
Other questions:
  • Mark, David, Tia, and Ashley are team members in a computer programming class. They have been assigned the task of creating a co
    12·1 answer
  • The technology (software) that automatically downloads website information to your computer is called ________.'
    15·1 answer
  • Written and artistic expressions are protected by
    8·1 answer
  • What needs to be increased in order to increase image size and clarity?
    10·1 answer
  • 3.24 LAB: Seasons
    13·1 answer
  • A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
    12·1 answer
  • The purpose of​ a/an _________ system is to capture best practice solutions and program them into a set of rules in a software p
    13·1 answer
  • How do ice and water on the ground affect incoming solar radiation? They filter 22 percent of solar radiation that reaches the s
    9·2 answers
  • What is the main purpose of a web crawling program
    15·1 answer
  • A type of user interface that features on- screen objects, such a menus and icons, manipulated by a mouse.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!