python basics Flashcards

(33 cards)

1
Q

in print what is the + used for

A

to join two strings

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

in print what is a , used for

A

to join a string and a int

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

what would the output of this line of code print(“test”,”test”)

A

test test , give a space

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

the to parts of this line are called what print(“test”)

A

funtion and peramitor

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

what is the \ used for

A

escaped charictor turns the next charictor into a aski eg cancels its funtion

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

what are the two ways of fixing the \ in file paths

A

replace all \ with \ or /

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

what are the three basic maths symbols

A

+ - * /

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

what is the turm used in programing for decimal numbers

A

float

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

what is used as the formula for the power of

A

**

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

what is the syntax for creating a var

A

var = 100

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

can you put a funtion in a variable

A

yes

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

can you write out a funtion in a varible

A

var = othervar / 5.3

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

explain while loop in a sentence

A

while something is the case do something

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

write down the start of a while loop

A

var = 10
while var <10:

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

how do you end the first line of a while loop

A

:

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

what does this code do conditon += 1 do

A

adds one to the variable

17
Q

what does += do

A

adds one to a varible

18
Q

what is another way to write var = var + 1

19
Q

what is the simbol for a single line comment

20
Q

how do you comment multiple lines at once

21
Q

write a quick while loop

A

example
var
while var <10:
var += 1

22
Q

how do you stop a script running

23
Q

what is a simpol way to make a infinite loop using while

A

while True:
print(“ahhh”)

24
Q

write out a basic list

25
what will this code print list = [1,2,3,4,5] for thing in list: print(thing)
1 2 3 4 5
26
what is a common use for if statments
iterate through list
27
what will this code print for x in range (1,10): print (x)
1 2 3 4 5 6 7 8 9 (goes up to but does not include last number)
28
what is the biggest diffrence between if and while
if statements only run the code once, while statements will keep running
29
what will the output of this code be x = 2 y = 7 7 = 10 If x > y: print(x,'is greater than' y) if x
2 is less than 7 there will be spaces as a , was used
30
what is the diffrence between = ==
= is a assinment opperator not a comparison operator
31
what is the code for less than or equal too
<=
32
can you modify a gobal varible in a funtion
no (you would have to assign the the global var to a local var to make changes
33