GOEDUHUB Tutorials    ||    AI    ||    ML  ||    NLP    ||    OpenCV    ||    Python    ||    OOPS    ||    DBMS    ||    DSA    ||    JAVA    ||    Linux    ||    C Programming
7976731765 Go To Your University       ||       Placement Preparation       ||        Technical-MCQ and Interview Questions
Online Live Classes Youtube Live Link
0 like 0 dislike
59 views
in Python Programming by Goeduhub's Expert (8.1k 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 (8.1k 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')

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
 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
...