Chapter 3: Intro To Python Flashcards
What does IDE stand for?
Integrated Development Environment
What is the function of IDE?
- Allows common activities of writing software such as:
- editing source code
- building executables
- debugging - Help identify programming errors
What are examples of IDE for python?
- IDLE Python
- Eclipse
- PyDev
Common errors in programming:
- Syntax Error
- Runtime Error
- Logic Error
Syntax Error
- indentation
- spelling errors
Runtime error
- doesnt appear until program is run
- error message pops up
- called EXCEPTIONS
example of runtime error
- division by zero
- using identifier that hasnt been defined
Logic error
- expected output != actual output
- code will run successfully(doesn’t generate error messages)
- to identify: tracing step by step, understand what the code does
How to write comments
- using #…
- using “””…”””
How to check the reserved python words?
import keyword
keyword.kwlist
Rules for naming variables:
- start with LETTER or UNDERSCORE
- CANNOT START W NUMBERS
- cannot use keywords
- only contain alpha-numeric & underscores
- case-sensitive(age!=Age!=AGE)
How to differentiate constant from variable?
use UPPERCASE to represent a constant
What are the Built-in data types by default?
- Text type
- Numeric Types
- Boolean Types
- Sequence(list tuple range)
- Binary
How can a programmer get the data type of an object?
using type() function:
x = 5
print(type(x))
output: <class ‘int’>
How are the boolean keywords written as?
lower case:
- and/or/not
Python formatting:
x = 8, y = 10
print(“the value of x is {} and y is {}”.format(x,y))
x = 12.3456789
print(“the value of x is %3.2f” %x)
print(“the value of x is %3.4f” %x)
How to use the functions in math module?
use
import math
#request input as usual
num = int(input(“please input a number: “)
#specify MODULE and FUNCTION
print (math.tan(float(num)))