Data types, variables, basic input-output operations, basic operators Flashcards

1
Q

What is a function able to do?

A
  • cause some effect
  • evaluate a value and return it as the functions result
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the function invocation?

A

The function name along with parentheses and arguments

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

What happens when python encounters an invocation? e.g. funct_name(argument)

A
  • check if the name if legal
  • check if function requirements for arguments allows you to invoke the function in this way
  • leaves your code and jumps into function you want to invoke
  • executes code, causes desired effect
  • returns to your code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Does python allow more than one instruction in a line?

A

No

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

How do you create a new line in python?

A

\n

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

What is the escape character?

A

\

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

What are the two ways of passing arguements?

A

Positional way and keyword arguments

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

What are they elements and one rule for the keyword argument?

A

Elements = keyword, equal sign and value
Rule = have to be put after the last positional argument

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

What are the two keyword arguments for print?

A

end and sep

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

What is a positional argument?

A

Ones whose meaning is dictated by their position

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

What is a keyword argument?

A

Ones whose meaning is not dictated by their location, but by a special word (keyword) used to identify them

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

What is a literal?

A

A literal is data whose values are determined by the literal itself.

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

How are numbers handle by computers?

A

Integers (no fractional part)
Floating point numbers

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

What is the numeric type?

A

The characteristic of the numeric value which determines its kind, range, and application

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

What is the prefix for octal numbers?

A

0o (zero - o)

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

What is the prefix for hexadecimal numbers?

A

0x (zero - x)

17
Q

Other than a . what else can make a number a float?

A

e (exponential)

the exponent (the value after the E) has to be an integer;
the base (the value in front of the E) may be an integer

18
Q

What are python literals?

A

Integers
Floats
Strings
Boolean values

19
Q

What is an operator?

A

An operator is a symbol of the programming language, which is able to operate on the values.

20
Q

If you multiply an integer by a float the answer is a …

A

float

21
Q

The result produce by a division operator is always …

A

a float

22
Q

What does the // operator do?

A

It is integer division.
it round the integer to the lesser integer value (floor division)

e.g.
6 // 4 = 1
-6 // 4 = -2 (cos -2 is the lesser value closest to -1.5
)

23
Q

What does the % operator do?

A

Modulo operator
The result of the operator is a remainder left after the integer division.

14 // 4 gives 3 → this is the integer quotient;
3 * 4 gives 12 → as a result of quotient and divisor multiplication;
14 - 12 gives 2 → this is the remainder.

24
Q

What are the two type of operator?

A

Unary and binary

25
Q

What is operator priority?

A

1 **
2 +, - (note: unary operators located next to the right of the power operator bind more strongly) (unary)
3 *, /, //, %
4 +, - (binary)

26
Q

What is operator binding?

A

Determines the order of computations performed by some operators with equal priority, put side by side in one expression.

** right sided binding
// left sided binding

27
Q

What is operator binding?

A

Determines the order of computations performed by some operators with equal priority, put side by side in one expression.

** right sided binding
// left sided binding

28
Q

What does a python variable have?

A

A name and a value

29
Q

What can’t you name a variable or functions?

A

a number
a reserved keyword
must not have spaces

30
Q

What is the equal sign?

A

An assignment operator

31
Q

How can this be rewritten?
variable = variable op expression

A

variable op= expression

32
Q

What is a remark that is omitted at run time?

A

a comment

33
Q

Name two functions of python comments

A
  • make code easier to understand
  • disable pieces of code that aren’t currently needed
34
Q

What does the input function do?

A

The input() function is able to read data entered by the user and to return the same data to the running program.

35
Q

What is a deaf program?

A

A program which doesn’t get a user’s input

36
Q

What two operators can be used on strings?

A

+ and *

37
Q

What do you have to be careful with the input function?

A

If the input is not converted to float or int it is STRING
x = input(4)
y=input(6)
print(x+6)
‘46’