Liz L.

asked • 11/14/23

Need help with basic Python conditional statements

Hi, everyone!


I would like to request some assistance with an activity that I'm tasked to complete (see below). I believe that I am simply not understanding independent if-else statements -- and how a line of code will execute if it meets (condition). Reading my textbook and trying various iterations of the same code is not helping me. Any assistances and/or other readable online resources would be much appreciated! Thanks much!


-----


user_num1 and user_num2 are read from input.

• If user_num1 is less than 0, output 'user_num1 is negative'.

• If user_num2 is greater than 14, assign user_num2 with 2.

• Otherwise, output 'user_num2 is less than or equal to 14'.


My work:


user_num1 = int(input())

user_num2 = int(input())

if user_num1 < 0:

print('user_num1 is negative')

if user_num2 > 14:

user_num_2 = 2

print('user_num2 is', user_num2)

else:

print('user_num2 is less than or equal to 14')



1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.