More Errors! - Introduction to Python: Absolute Beginner Module 1 Video 13

Veröffentlicht am: 24 Juli 2021
auf dem Kanal: Book Simplifiers
826
28

Concept: Errors
More Errors!
SyntaxError & NameError
SyntaxError - breaks code formatting rules of python
NameError - object is not defined (can't be found)
Python has a specific grammar that it follows that is referred to as syntax.
The print function syntax rules for output of a single string include

parentheses ( ) containing a string follow print (SyntaxError)
strings have matching quotation marks (SyntaxError)
print is lowercase and correctly spelled (NameError)
Failure to follow any of these rules results in a SyntaxError or NameError when the code is run

Example
SyntaxError

Improperly formatted string (quotes don't match) that results in a SyntaxError
[ ] review and run the code for properly and improperly formatted print statement
print("Hi!")
improper format - non matching quotes
print('I like the morning")
Note that the "prin" misspelling below results in a NameError
[ ] review and run the code
prin('hi')
EOF = "end of file" found in code below
Python went to the end of the file looking for, but not finding, a closing parenthesis
[ ] review and run the code missing the closing parenthesis
print("where are my socks?"
In code below: a parenthesis inside quotations will be seen a part of a string and not as a parenthesis
{ ] review and run the code
print("my socks are in the wrong bin)"
Task 4
Fix Errors
Tip: explaining errors to a partner often reveals a solution (works even if explaining error to a pencil)

[ ] repair the syntax error
print('my socks do not match")


[ ] repair the NameError
pront("my socks match now")


[ ] repair the syntax error
print"Save the notebook frequently")


[ ] repair the NameError
student_name = "Alton"
print(STUDENT_NAME)


[ ] repair the TypeError
total = 3
print(total + " students are signed up for tutoring")


A parenthesis inside quotations will be seen a part of a string and not as a parenthesis


Auf dieser Seite können Sie das Online-Video More Errors! - Introduction to Python: Absolute Beginner Module 1 Video 13 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Book Simplifiers 24 Juli 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 826 Mal angesehen und es wurde von 28 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!