Python intro Flashcards

1
Q

y:float

A

for decimal numbers

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

x:int

A

whole numbers

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

b:bool

A

True or False (with capitals)

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

s:str

A

string for text

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

%

A

modulus, how many times the number goes in. Looking at remainder

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

//

A

integer division, ignore decimal in division, becomes an int.

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

**

A

exponent

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

Cast str to float

A

s: str = “1.0”
x: float = (s)

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

cast str to int

A

s: str = “1”
y:int = int (s)

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

=

A

assignment/becomes

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

7%2

A

1

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

36%4

A

0

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

false == false

A

true (false is the same as false)

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

print (1!=2)

A

true (1 does not equal 2)

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

how toprint what type of value

A

print(type(…))
to show int, float, bool, ect.

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

how to start and end turtle graphics

A

import turtle, t=turtle.Turtle(), turtle.done

17
Q

How to move pen

A

t.penup()
t.goto(x,y)
t.pendown()

18
Q

How to print from multiple lines on one line

A

print(“A”,”B”,end=” “)
print(“E”,”F”) #A B E F

19
Q

loop

A

repeats code

20
Q

format for loop

A

for i range (0,10,1)
print(i)
make sure to indent otherwise won’t work

21
Q

what is the meaning of (0,10,1)

A

(from 0, to but no including 10, incrementally by 1)

22
Q

what is default increment and start

23
Q

if you change print function to
print(i+1)

A

increases starting number by 1 making it include to number to

24
Q

How do you make a loop function not run without causing error

25
nested loop
multiple loops/assignments in loop
26
what would happen if you ran for j in range (0,5,1) for i in range (0,10,1) print(“A”)
would print A 50 times (5*10)
27
How to use math functions
import math
28
what is a string concatenation
glues strings together
29
\n
new line
30
\t
tab
31
index
refers to certain letter/character in length
32
index
refers to certain letter/character in length
33
How to print x as uppercase
print(x.upper())