Chapter 3: Intro To Python Flashcards

1
Q

What does IDE stand for?

A

Integrated Development Environment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the function of IDE?

A
  1. Allows common activities of writing software such as:
    - editing source code
    - building executables
    - debugging
  2. Help identify programming errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are examples of IDE for python?

A
  1. IDLE Python
  2. Eclipse
  3. PyDev
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Common errors in programming:

A
  1. Syntax Error
  2. Runtime Error
  3. Logic Error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Syntax Error

A
  • indentation
  • spelling errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Runtime error

A
  • doesnt appear until program is run
  • error message pops up
  • called EXCEPTIONS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

example of runtime error

A
  • division by zero
  • using identifier that hasnt been defined
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Logic error

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to write comments

A
  1. using #…
  2. using “””…”””
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to check the reserved python words?

A

import keyword
keyword.kwlist

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Rules for naming variables:

A
  1. start with LETTER or UNDERSCORE
  2. CANNOT START W NUMBERS
  3. cannot use keywords
  4. only contain alpha-numeric & underscores
  5. case-sensitive(age!=Age!=AGE)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to differentiate constant from variable?

A

use UPPERCASE to represent a constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the Built-in data types by default?

A
  1. Text type
  2. Numeric Types
  3. Boolean Types
  4. Sequence(list tuple range)
  5. Binary
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can a programmer get the data type of an object?

A

using type() function:
x = 5
print(type(x))

output: <class ‘int’>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How are the boolean keywords written as?

A

lower case:
- and/or/not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Python formatting:

A

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)

17
Q

How to use the functions in math module?

A

use

import math
#request input as usual
num = int(input(“please input a number: “)
#specify MODULE and FUNCTION
print (math.tan(float(num)))