Chris

21%
Flag icon
admission price. This code produces the same output as the previous example, but the purpose of the if-elif-else chain is narrower. Instead of determining a price and displaying a message, it simply determines the admission price. In addition to being more efficient, this revised code is easier to modify than the original approach. To change the text of the output message, you would need to change only one print() call rather than three separate print() calls. Using Multiple elif Blocks You can use as many elif blocks in your code as you like. For example, if the amusement park were to ...more
Python Crash Course, 3rd Edition: A Hands-On, Project-Based Introduction to Programming
Rate this book
Clear rating
Open Preview