186k views
3 votes
Given integers numScore1 and numScore2, output "numScore1 is greater than or equal to 40." if numScore1 is greater than or equal to 40. End with a newline.

Assign numScore2 with 2 if numScore2 is greater than 20. Otherwise, output "numScore2 is less than or equal to 20." End with a newline.

Ex: If the input is 65 -20, then the output is:

numScore1 is greater than or equal to 40.
numScore2 is less than or equal to 20.
numScore2 is -20

User Ryan Ward
by
8.6k points

1 Answer

1 vote

Answer:

Here's the Python code to solve the problem:

numScore1, numScore2 = map(int, input().split())

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40:

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40: print("numScore1 is greater than or equal to 40.")

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40: print("numScore1 is greater than or equal to 40.")else:

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40: print("numScore1 is greater than or equal to 40.")else: print("numScore1 is less than 40.")

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40: print("numScore1 is greater than or equal to 40.")else: print("numScore1 is less than 40.")if numScore2 > 20:

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40: print("numScore1 is greater than or equal to 40.")else: print("numScore1 is less than 40.")if numScore2 > 20: numScore2 = 2

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40: print("numScore1 is greater than or equal to 40.")else: print("numScore1 is less than 40.")if numScore2 > 20: numScore2 = 2else:

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40: print("numScore1 is greater than or equal to 40.")else: print("numScore1 is less than 40.")if numScore2 > 20: numScore2 = 2else: print("numScore2 is less than or equal to 20.")

numScore1, numScore2 = map(int, input().split())if numScore1 >= 40: print("numScore1 is greater than or equal to 40.")else: print("numScore1 is less than 40.")if numScore2 > 20: numScore2 = 2else: print("numScore2 is less than or equal to 20.")print("numScore2 is", numScore2)

Step-by-step explanation:

In this code, we first read two integers numScore1 and numScore2 from the user using input(), and then convert them to integers using map(int, input().split()).

We then use an if statement to check if numScore1 is greater than or equal to 40. If it is, we print the message "numScore1 is greater than or equal to 40." on a new line. Otherwise, we print the message "numScore1 is less than 40." on a new line.

Next, we use another if statement to check if numScore2 is greater than 20. If it is, we assign numScore2 the value 2. Otherwise, we print the message "numScore2 is less than or equal to 20." on a new line.

Finally, we print the value of numScore2 on a new line, along with the message "numScore2 is". Note that we use a comma to separate the message and the value of numScore2, which will automatically insert a space between them. The output for the given input "65 -20" will be:

numScore1 is greater than or equal to 40.

numScore1 is greater than or equal to 40.numScore2 is less than or equal to 20.

numScore1 is greater than or equal to 40.numScore2 is less than or equal to 20.numScore2 is -20

User ReachConnection
by
7.6k points