-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors2.py
More file actions
29 lines (21 loc) · 882 Bytes
/
errors2.py
File metadata and controls
29 lines (21 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# This example program is meant to demonstrate errors.
# There are some errors in this program. Run the program, look at the error messages, and find and fix the errors.
# Original:
# animal = Lion
# animal_type = "cub"
# number_of_teeth = 16
# SYNTAX ERROR: Lion is not defined. It should be a string.
animal = "Lion"
animal_type = "cub"
number_of_teeth = 16
# Original:
# full_spec = "This is a {animal}. It is a {number_of_teeth} and it has {animal_type} teeth"
# SYNTAX/LOGICAL ERROR: The variables were not being formatted into the string. We need to use an f-string.
# LOGICAL ERROR: number_of_teeth and animal_type were in the wrong order
full_spec = (
f"This is a {animal}. It is a {animal_type} and it has {number_of_teeth} teeth"
)
# Original:
# print full_spec
# SYNTAX ERROR: Missing parentheses in call to 'print'. Did you mean print(...)?
print(full_spec)