Last active
January 5, 2020 21:24
-
-
Save MatrixManAtYrService/dc4a2eae88bca999ad6ddbf3aa636046 to your computer and use it in GitHub Desktop.
Python 3.6 f-strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
adult_price = 120 | |
child_price = 60 | |
total_tickets_purchased = 3 | |
adult_ticket = 3 | |
child_ticket = 0 | |
availble_seats = 150 | |
adult_cost=adult_price*adult_ticket | |
child_cost=child_price*child_ticket | |
total_cost=adult_cost+child_cost | |
total_tickets_purchased=(adult_ticket+child_ticket) | |
seats_left=availble_seats-child_ticket-adult_ticket | |
# INSTEAD OF THIS | |
print(" Session summary ") | |
print("The amount of adult tickets purhcased is",adult_ticket) | |
print("The amount of child tickets purchased is",child_ticket) | |
print("The total tickets purchased is",total_tickets_purchased) | |
print("****************************************************") | |
print("The total cost of adult ticket is",adult_cost) | |
print("The total cost of child tickets is",child_cost) | |
print("The total cost of the tickets is",total_cost) | |
print("The remaining seats left is",seats_left) | |
# I WOULD DO THIS | |
print(f''' | |
Session summary | |
The amount of adult tickets purhcased is {adult_ticket} | |
The amount of child tickets purchased is {child_ticket} | |
The total tickets purchased is {adult_ticket + child_ticket} | |
**************************************************** | |
The total cost of adult ticket is {adult_cost} | |
The total cost of child tickets is {child_cost} | |
The total cost of the tickets is {total_cost} | |
The remaining seats left is {seats_left} | |
''') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yeah that's the problem the computers in school run python 3.5 so I wouldn't be able to do it like that but thank you for suggesting it .