Python 2 Flashcards
What are the types of errors in Python?
-Syntax errors
-Semantics error
-Runtime errors
What is a syntax error and name cases where it might happen?
-When the computer does not recognize the statement to be executed, a syntax error is generated.
-A misspelled code in programming language
-Python is case sensitive so capital letters can cause a syntax error, ex: Print and not print
What is semantic error?
Python will run successfully and the computer wont generate any error message however it will not do the thing you wanted it to do
What are runtime errors?
Type of error that do not appear after the program has started running.
-They are also called exceptions because they indicate something exceptional and bad has happened
-It is very rare
What are bugs?
Programming errors
What is debugging?
Process of tracking programming errors down
What is a Python interpret?
To execute a program in a hugh level language by translating it one line at the time
What is Python compile?
To translate a program written in a high-level
language into a low-level language all at once, in preparationfor later execution
What is interactive mode?
A way of using the Python interpreter by
typing commands and expressions at the prompt
What is script mode?
A way of using the Python interpreter to read and
execute statements in a script file.
What does script mode do?
-Write, edit, save, and run
-Word processor for your code
-Save your file using the “.py” extension
What does interactive mode in Python give you?
Gives you immediate feedback and it is not designed to create programs to save and run later
What is a string?
A sequence of characters surrounded by “ “ or ‘ ‘
What is the purpose of Triple Quotes?
Enclose strings containing both single and double quotes such that no escaping is needed.
* Enclose multi-line strings.
Why did this produce a syntax error?
»> “hello’ and what syntax error does it produce?
-It mixes the quotes “ and ‘
-File “<stdin>", line 1
"hello'
^SyntaxError: EOL while scanning string literal</stdin>
Why does this produce a syntax error?
»> ‘It’s a bad example’ and how to fix it?
-The quote ‘ is used three times
-You can add a backslash before the quote
ex: ‘ It\ ‘ s a good example ‘
-You can use a double quote as the enclosing quote
What is an escape sequence?
A special sequence of characters that provide
more functionality to the displayed text
What does \ do?
It is a backslash and it prints one backslash.
What does ' do?
Single quote, it prints one single quote
ex:»_space;> ‘It/’s getting cold’
output: “It’s getting cold.”
What does " do?
Double quote; it prints a double quote.
ex:»_space;> “It"s getting cold”
output: “It”s getting cold”
What does \a do?
Bell, sounds the system bell
What does \b do?
Backspace, moves the cursor back one space.
What does \n do?
New line, moves the cursor to the beginning of next line.
What does \t do?
Horizontal tab, moves cursor forward one tab stop