136,179 views
17 votes
17 votes
write an if-else statement that assigns finalvalue with uservalue 5 if uservalue is greater than 100. otherwise assign finalvalue with

User VRPF
by
2.8k points

1 Answer

17 votes
17 votes

Answer:

Here is an if-else statement that assigns finalvalue with uservalue + 5 if uservalue is greater than 100. Otherwise, it assigns finalvalue with uservalue - 5.

if uservalue > 100:

finalvalue = uservalue + 5

else:

finalvalue = uservalue - 5

Step-by-step explanation:

In this statement, we first check if uservalue is greater than 100. If it is, we assign finalvalue with the value of uservalue + 5. Otherwise, we assign finalvalue with the value of uservalue - 5.

This if-else statement provides a simple way to assign a value to finalvalue based on the value of uservalue. If uservalue is greater than 100, finalvalue will be assigned a value that is 5 greater than uservalue. Otherwise, finalvalue will be assigned a value that is 5 less than uservalue.

User Andrei Savin
by
3.0k points