Python Basics
Runtime Error
If your program needs to read data from a file, but the file does not exist, an error would occur when running this program. What kind of error is this?
syntax errors, runtime errors, and logic errors
What are three kinds of program errors?
Python was created by _____
Guido van Rossum
____ is an object-oriented programming language.
Java, C++, C#, & Python
Can a program written using Python 3 run in Python 2?
No
Is Python case sensitive?
Yes
What are the two modes you can run Python in?
You can run Python in script mode or interactive mode. Running a Python program from a script file is known as running Python in script mode. Typing a statement at the >>> prompt and executing it is called running Python in interactive mode.
Pseudocode
___ is the code in natural language mixed with some program code.
Logic
_______ error does not cause the program to abort, but produces incorrect results.
String
a programming term meaning a sequence of characters
Pseudocode
describes algorithms using natural language mixed with code.
Algorithm
describes how a problem is solved by listing the actions that need to be taken and the order of their executions.
interpreter/at runtime
In Python, a syntax error is detected by the ________ at _______
IDLE
is Interactive DeveLopment Environment for developing and running Python code.
Line comment
is a text preceded by a pound sign (#) on a line.
#
A Python line comment begins with ___
Logic Error
Suppose you write a program for computing the perimeter of a rectangle and you mistakenly write your program so that it computes the area of a rectangle. What kind of error is this?
What is the Python source filename extension by convention?
The Python source code filename extension is .py.
Data Type
is the type of the value stored in a variable.
Script Mode
is to run a Python program from a script file.
Logic Error
occurs when a program does not perform its intended task.
What is the statement to display the message "Hello world" to the console?
print("Hello World")
To start Python from the command prompt, use the command ____
python
To run python script file named t.py, use the command _____
python t.py
Variable
represents a value stored in the computer's memory.
Runtime Error
causes a program to terminate abnormally.
Syntax Error
is detected by the interpreter.
Interactive Mode
is to type a statement at the >>> prompt and to execute it.
Syntax Error
If you forget to put a closing quotation mark on a string, what kind error will be raised?
Can a program written in Python 2 run in Python 3?
No. Python 3 is a newer version, but it is not backward-compatible with Python 2.
Python is interpreted. What does that mean?
Python is interpreted, which means that python code is translated and executed by an interpreter one statement at a time. In a compiled language, the entire source code is compiled and then executed altogether.