CHAPTER 1 Flashcards

IN THIS WE ARE GONNA INTRODUCE YOU TO PYTHON

1
Q

Define Script.

A

a python program

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

Define python command.

A

a python program statement

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

Define shell.

A

commands and definitions are executed by the python interpreter.

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

Python features.

A

a. simple and easy program structure.
b. portable and free available library.
c. easy for debugging and testing.
d. supports structured and functional programming methods as well as object-oriented programming.
e. provides dynamic type checking and very high-level dynamic data type.
f. it has automatic garbage collection.
g. integration with c++, c, CORBA, java is very easy.

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

Types of objects.

A

scalar and non-scalar

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

Scalar Objects

A

they are considered invisible objects.

example: int, float, bool, none.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. int
  2. float
  3. bool
  4. none
A
  1. used to represent integers(ex:- 3,4, -60, 02).
  2. used to represent real numbers with decimal points(-0.5, 6.0, 9.9).
  3. represent two boolean values that are true or false.
  4. it is a type with a single value.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Non-scalar objects

A

Strings

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

Define expression.

A

combination of operators and objects.

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

’==’ operator

’!=’ operator

’»>’

A

to check whether the two expressions are the same or the same two values.

to test whether the two expressions evaluate different values.

it indicates the user to type some code in the shell

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

a//b

A

it means it will always return a result of type int since it returns the quotient and ignores the remainder. ex: 7/3 will return 3.

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

a**b

A

a raised to the power b. ex: 5**3=125

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

precedence

A

Parentheses&raquo_space; Exponent&raquo_space; Unary plus, Unary minus, Bitwise NOT&raquo_space; Multiplication, Division, Floor division, Modulus&raquo_space; Addition, Subtraction&raquo_space; Bitwise shift operators&raquo_space; Bitwise AND&raquo_space; Bitwise XOR&raquo_space; Bitwise OR&raquo_space; Comparisons, Identity, Membership operators&raquo_space; Logical NOT&raquo_space; Logical AND&raquo_space; Logical OR

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

Define variables.

A

a way to associate names with objects. it is just a name.

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

What is an assignment statement?

A

it is used to assign value to the variable. It associates the name of the variable with the object represented by the expression to the right side of the assignment operator(=).

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

strings

A

represented by str.
can be written between single or double-quotes.
an ordered sequence of characters: “hello” ‘Sammy’ “2000”.

17
Q

overloading operator

  1. *
A
  1. it means addition when applied to two numbers and concatenation when applied to two strings.
  2. it means multiplication when applied to two numbers and when applied to an int and string it will duplicate the str.
    ex: 4 * ‘p’ = ‘p’+’p’+’p’+’p’
18
Q

Define slicing.

A

it is used to extract substrings of arbitrary length.

19
Q

indexing

A

in python, it starts from 0 and ends at length-1.
s[start: end] means index start and ends at index end-1.
ex: ‘pqr’[1:3]= ‘qr’
if the value before the colon is omitted then it considers 0 as default and if the value is omitted after colon then it considers the length of the string.
‘pqr’[:] == ‘pqr’[0:len(‘pqr’)]

20
Q

Branching programs

A

it has three parts:

  1. a test condition.
  2. a block of code that is executed if the test evaluates to true
  3. an optional block o code that is executed if the test evaluates to false.
21
Q

Syntax of the conditional statement

A

if Boolean expression:
block of code
else:
block of code

22
Q

Iteration

A

another form of control structure.

23
Q

built-in data types in python.

A

numbers, list, tuple, string, set, dictionary