If-elif and if-elif-else statements are other common conditional statements. Learn when and how to write these.
- [Instructor] An IF-ELIF statement instructs the computer … to perform a certain action if a certain condition is met, … or a different action if a different condition is met. … For example, say you ask a user if it's raining … and if they have an umbrella. … And based on the user's responses, … a relevant message is displayed to the user. … You could use an IF-ELIF statement to do this. … I can start by creating a variable named raining, … and set it to the user's response … to the prompt is it raining? … Yes or no. … On this line, I can create another variable named umbrella, … and set it to the user's response … to the prompt do you have an umbrella? … Yes or no. … And on this line, I'll begin to write an IF-ELIF statement. … I start with the keyword if, … followed by a compound condition, … since I want to check two things here. … I want to check whether raining is yes, … and umbrella is yes. … So I'll write raining equals equals yes, … and umbrella equals equals yes, colon. … If this compound condition is satisfied, I want to print out, …
Released
10/8/2019This course was created by Madecraft. We are pleased to host this content in our library.

- What is Python?
- Strengths and benefits of Python
- Types of data
- Storing data using variables
- Built-in and custom functions
- Lists and tuples
- Conditional statements
- Iteration with loops
- Recursive functions
- Object-oriented programming
Skill Level Beginner
Duration
Views
Related Courses
-
Learning Python
with Joe Marini2h 27m Beginner -
Learning the Python 3 Standard Library
with Kathryn Hodge2h 9m Intermediate -
Python Standard Library Essential Training
with Joe Marini2h 18m Intermediate
-
Introduction
-
1. Defining Python
-
What is Python?1m 4s
-
Why Python?1m 8s
-
Python vs. Java1m 24s
-
-
2. Fundamentals of Programming in Python: Data
-
Set up Python environment3m 44s
-
Types of data3m 33s
-
Store data using variables3m 19s
-
-
3. Fundamentals of Programming in Python: Functions
-
What is a function?1m 42s
-
Types of functions8m 51s
-
Modules in Python6m 38s
-
-
4. Fundamentals of Programming in Python: Sequences
-
What is a sequence?1m 10s
-
Lists in Python4m 39s
-
Tuples in Python6m 28s
-
-
5. Fundamentals of Programming in Python: Conditional Statements
-
If statement3m 22s
-
If-else statement3m 58s
-
6. Fundamentals of Programming in Python: Iteration
-
What is iteration?3m 24s
-
For loop4m 35s
-
While loop2m 37s
-
-
7. Fundamentals of Programming in Python: Recursion
-
Define recursive functions6m 13s
-
8. Quick Intro to Object-Oriented Programming in Python
-
Conclusion
-
Next steps1m 8s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: If-elif and if-elif-else statements