Conditional Steps (If Loop)

Hi Sandeep,

Need to know that if loop can have multiple condition instead of 1 check of condition.

Thanks and Regards
(Parixit Jadav)

if is not really a loop instead it is the condition. The following code should answer your curiosity.

if x > 100:
    print("x is greater than 100")
elif x > 10:
    print("x is between 10 and 100")
else:
   print("x is less than 10")

You must try it by yourselves.

Thanks for the quick reply, I got the option and tried.

Doubt cleared.

Hi Have another question, i was going to the course i found this question but not to able to understand the problem statement, please help me to understand in details.

Question:-

The statement “sam” in names where names is a dictionary results in

  1. True if “sam” is in the values of the dictionary names
  2. True if “sam” is in the keys of the dictionary names
  3. False because names is a dictionary and “sam” is a string
  4. TypeError

Hi @Parixit_Jadav Please open a different discussion post for different questions in future.

The question is fairly straightforward. You have a dictionary named names. Now you have a statement in Python

"sam" in names

The question asks you what will it return when you invoke the statement in a Python interpreter. I encourage you to go run it on CloudxLab Jupyter lab and then check the results yourself. In this way, you will be able to understand what is the output and why that is the output.

Also, read about in operator in Python

Happy learning!