Python Flashcards

1
Q

modulus operator %

A
  • The operands can be either integers or floats.
    -finds the remainder or signed remainder after the division of one number by another.
    ex: 13%5=3
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

// floor division

A

will divide the first argument by the second and round the result down to the nearest whole number

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

syntax for a to the power of b

A

a**b

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

print(False or False or False or True)

how does this expression evaluate?

A

True - or operator needs only one to be true

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

how do we check to see if a is divisible by b?

A

a%b==0

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

what is the outcome of
print(2>3 and 3<=7) ?

A

False and True

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

how do we write multi-line comments?

A

””” (begin and end with 3 double quotes)
‘’’ (begin and end with 3 single quotes

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

for i in s

loop syntax…what is i?

A

i is the variable that will store the elements of the sequence one by one

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

what is a continue statement?

A

a loop control statement that forces to execute the next iteration of the loop while skipping the rest of the code inside the loop for the current iteration only.

ex:

for var in “Geeksforgeeks”:
if var == “e”:
continue
print(var)

output will be Gksforgks, every e is skipped

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

what is range expression syntax?

A

range(begin, end, intervals)

where begin = the starting number. default is 0
end = one MORE than the number you want to end on
intervals = the intervals at which we want selected along the number line (range)

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

what is the simplest way we can express a range?

A

range(integer), which will give us 0 thru the number BEFROE the integer in parentheses

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

how do we express a range that we want to iterate 5 times?

A

range(0, 6)

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

what is the difference between a while loop and a for loop?

A

a FOR LOOP used to iterate over a sequence of items. will execute a block of statements for each item in the sequence.

a WHILE LOOP is used to repeatedly execute a block of statements while a condition is true. The loop will continue to run as long as the condition remains true.

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

what is a factorial?

A

he product of all positive integers less than or equal to a given positive integer and denoted by that integer and an exclamation point. Thus, factorial seven is written 7!, meaning 1 × 2 × 3 × 4 × 5 × 6 × 7

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