GOEDUHUB Online Courses || Last Batch Student's Projects || COVID-19 Projects(AI-ML) || Universities  ||  Placement Preparation  Subscribe our youtube channel
+91-7976731765 Free Online Tutorials ||  MACHINE LEARNING || NLP ||  OpenCV || Python || DBMS || OOPs || DSA || Java || Linux/Unix ||  C Programming
0 like 0 dislike
39 views
in Python Programming by Goeduhub's Expert (8k points)

What are the decision making statements in python? How do you write an IF ELSE statement in Python?

1 Answer

0 like 0 dislike
by Goeduhub's Expert (8k points)
selected by
 
Best answer

# Decision making

print ('What would you like to drink?')

print( '1. coffee')

print ('2. tea')

# Take input from user

drink = raw_input("> ")

# If the user has entered '1' enter if conditional statement 

if drink == '1':

print ('What kind of coffee would you like?')

print ('1. Irish')

print ('2. Americano')

coffee = raw_input("> ")

# If the user has entered '1' enter if conditional statement 

if coffee == '1':

print ('Irish coffee served')

elif coffee == '2':

print( 'Americano coffee served')

else:

print ('Any coffee should be fine')

# If the user has entered '2' enter elif conditional statement 

elif drink == '2':

print( 'What kind of tea would you like?')

print ('1. Green tea')

print ('2. Black tea')

tea = raw_input("> ")

if tea == '1':

print ('Green tea served')

elif tea == '2':

print ('Black tea served')

else:

print ('Any tea should be fine')

# If the user has not entered '1' or '2' then enter else conditional statement 

else:

print( 'You have not choosen the right option')

 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Important Lists: List of NITsList of IITsList of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG)College ReviewsCollege Fest, Events & WorkshopsKnowledge ShareTrainees/Interns After 15-04-2020
Exams & Cutoffs: JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs || Cutoff-GATECutoff_IIT-JEECS-ScopeECE ScopeEE-Scope
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Goeduhub
About Us | Contact Us   Social::   |  | 
...