Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Class 10: Conditional Statements in Python [IF, ELIF, ELSE]

# 1. Create a new program in PyCharm where you will check the current weather and display funny messages based on user input.

print(" What kind of weather is it today? ")
weather = str(input())
if weather == 'sunny':
    print("time to put on glasses & shorts")
elif weather == 'clear':
    print ("hangout time")
elif weather == 'rain':
    print ("not again Raincouver")
elif weather == 'rainy':
    print ("not again Raincouver")
elif weather == 'cloudy':
    print("I am not going outside")
elif weather == 'hot':
    print("Lets grab some Ice Cream")
elif weather == 'Snow':
    print("Lets grab our shovel from backyard")
elif weather == 'Storm':
    print("Its time for some power outage")
elif weather == 'Stormy':
    print("Its time for some power outage")
elif weather == 'cold':
    print('noses are red ,fingers are blue, I am tired of winter, what about you ? ')
elif weather == 'windy':
    print(' Be careful with your hat, strong winds blowing ')
else:
    print("Whatever the weather is today, I believe Spring is coming soon")



# 2. If the user enters integer values more than 0 but less than 15 degrees, display a message to wear something related to that weather condition.

print(" What Do you think its temperature today my friend? ")
a = int(input())
if a <= 10: print("its a nice day for light sweater".format(a))
if a > 10: print("I am melting dude".format(a))

# 3. If the user enters integer values more than 15 but less than 35 degrees, display a message to wear something related to that weather condition.

print(" What Do you think its temperature today my friend? ")
a = int(input())
if 15 < a < 35: print("put on sun glasses and get ready for Kayak".format(a))


# 4. If the user enters integer values more than 35 degrees, display a message to wear something related to that weather condition.

print(" What Do you think its temperature today my friend? ")
a = int(input())
if a > 35: print("Yes! I am in formal relationship with my Air Conditioner now".format(a))

# 5. If the user enters integer values less than 0 degrees, display a message to wear something related to that weather condition.

print(" What Do you think its temperature today my friend? ")
a = int(input())
if a < 0: print("Dear Winter, I am breaking up with you. I think its time I start seeing other seasons. Summer is hotter than you".format(a))
Comment

PREVIOUS NEXT
Code Example
Python :: python mark function as no return 
Python :: python pprint on file 
Python :: quadrilateral 
Python :: using pickle to create binary files 
Python :: python selenium class 
Python :: input list in function and display column in dataframe python 
Python :: multiprocessing write to dict 
Python :: output multiple LaTex equations in one cell in Google Colab 
Python :: python - notification messages 
Python :: Using the token to make requests 
Python :: export ifc dataframe python 
Python :: exception: python in worker has different version 3.7 than that in driver 3.8, pyspark cannot run with different minor versions. please check environment variables pyspark_python and pyspark_driver_python are correctly set. 
Python :: pyqt5 cursor starting on a widget 
Python :: nltk python text from url 
Python :: showing typle results with for loop in py in one line 
Python :: text file sort by first item in each row 
Python :: python source script custom functions 
Python :: pythonmodules.txt 
Python :: calculate time between datetime pyspark 
Python :: django admin make column link 
Python :: converting 1d array into upper triangular 
Python :: let in python 
Python :: numpy move columns 
Python :: python web app with redis github 
Python :: sumif in python on a column and create new column 
Python :: code runner runs python 2 
Python :: python excel zelle schreiben 
Python :: pandas condense dataframe by summing according to ID 
Python :: discord.py get channel object from id 
Python :: python mypy cast 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =