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
The
saveliy_v [14]
The answer is Undo I think
4 0
2 years ago
Read 2 more answers
List any 5 Unix commands with their brief description?
AlexFokin [52]

Answer:

Commands: commands are also known as "programs" and the program is a set of rules that performs a specific task which is executed by a computer.

Unix is an operating system. that supports multi-tasking and multi-user functionality. Unix is most widely used in all forms of computing systems such as desktop, laptop, and servers. It provides a Graphical user interface similar to windows.

The Unix operating system there are various commands. The list of five Unix commands can be given as:

1) cal

2) date

3) banner

4) who

5) whoami

1)cal:

The cal command stands for calender. It displays the date.

Syntax:

$ cal

or

$ cal [[month] year]

Example:

$ cal 10 2019

2)date:

The date command stands for date and time. It displays the system date and time.

Syntax:

$date

or

$ date[+format]

Example:

$ date +%d/%m/%y

3) banner

The banner command stands for display the text in to a large size.

Syntax:

$banner message

Example:

$banner Unix

4) who

The who command stands for display the list of users currently logged in.

Syntax:

$who

or

$who [option] … [file][arg1]

Example:

$who

5) whoami

The whoami command stands for display the user id of the currently logged-in user.

Syntax:

$whoami

Example:

$whoami

Explanation:

1)cal command display the current month and year.

2)date command display system date and time.

3)banner command display text in large size.

4)who command display the user name who currently login.

5)whoami command display user id.

4 0
3 years ago
a circuit has an inductor with an inductive reactance of 230 ohms. this inductor is in series with a 500 ohm resistor. if the so
Amanda [17]

Answer: attached below

Explanation:

8 0
3 years ago
2.<br> The force of impact is
NNADVOKAT [17]

Answer:

lực ( Tiếng Anh : force ) là bất kỳ ảnh hưởng nào làm một vật thể chịu sự thay đổi, hoặc là ảnh hưởng đến chuyển động, hướng của nó hay cấu trúc hình học của nó.

Explanation:

7 0
3 years ago
Which role will grant a delegate read-only access to a particular workspace within a user’s Outlook mailbox?
DIA [1.3K]

Answer: i’m thinking it’s reviewer

Explanation:

4 0
2 years ago
Read 2 more answers
Other questions:
  • Helen has no experience in security. She would like to earn a certification that demonstrates that she has the basic knowledge n
    15·1 answer
  • Write an original idiom that uses the word dog or dogs im in 4th
    5·2 answers
  • Some files appear dimmed in one of the default folders on your computer. What would be the best course of action? A. Leave the f
    5·1 answer
  • 5. Which of the following views is used to run a PowerPoint presentation?
    11·2 answers
  • How should a Salesforce Admin fulfill those requirements? Universal Containers launches a Partner Community for their resellers
    13·1 answer
  • The dns server translates the URL into the IP address 8.8.8.8. What is the next step in the process?
    11·1 answer
  • Which operating system function has a steeper learning curve and can potentially break the system without careful use of its ope
    7·1 answer
  • Write an application that inputs a five digit integer (The number must be entered only as ONE input) and separates the number in
    10·1 answer
  • Collisions occur when one output is mapped to two inputs. <br><br> A. True <br> B. False
    7·2 answers
  • Ginny faced an application error while executing the recorder in opera. Which web browser is generally recommended to use with r
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!