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
What stage of software development incorporates planning to help make changes in the project plan based of reviews
larisa86 [58]

Answer:

A

Explanation:

8 0
3 years ago
What would the range(3, 9) function generate?
gregori [183]

Answer:

A, 3,6,9

is the answer

Explanation:

bc it count by

3 0
3 years ago
Common input devices include the keyboard, ____, and integrated video cameras.
Yuliya22 [10]
Common input devices include the keyboard, image scanner, and integrated video cameras. These also include the microphone, mouse, joystick controller, gamepad or joypad, webcam, digital pen, and others. Input devices are computer hardware used to control signals and provide data to a computer or an information appliance. 
4 0
3 years ago
Write a program in python to accept three numbers and print the largest of the three
Anika [276]

Answer:

num1 = int(input("Enter number 1: "))

num2 = int(input("Enter number 2: "))

num3 = int(input("Enter number 3: "))

print(max(num1,num2,num3))

Explanation:

Python 3

8 0
3 years ago
List four types of Web browsers<br>​
Mazyrski [523]

Answer:

interent just turn on chrome explore fire fox yahhoo

Explanation:

7 0
2 years ago
Read 2 more answers
Other questions:
  • The class Date has a single constructor that accepts the integer value: a month- (1 for January through 12 for December), a day
    13·1 answer
  • A ____ is a program that is installed without the permission or knowledge of the computer user, that is designed to alter the wa
    11·1 answer
  • Which fingers do you use to type the following letters rtgvf
    11·1 answer
  • Which action is LEAST important to maintaining a healthy credit score?
    8·2 answers
  • Jared does not update his computer’s system software. What threat does his computer face?
    9·1 answer
  • If you wanted to have wireless connectivity in your home or​ apartment, you would need a​ _________________ to move packets of d
    11·1 answer
  • 2. What is a cap? (0.5 points)
    9·1 answer
  • Create a Card class that represents a playing card. It should have an int instance variable named rank and a char variable named
    12·1 answer
  • I need help..
    15·1 answer
  • Select all the correct answers.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!