Python Basics Flashcards

1
Q

how do you pass a string as an instruction to output the string without ‘ ‘

A

print(stringname)

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

how do you import information about what version of python you’re using

A

import sys

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

what do you use to have python ignore everything you write past it in the same line

A

#

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

if you mistype a function, what type of error will you get

A

NameError

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

if you forget a “, what type of error will you get

A

SyntaxError

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

what type of object is ‘7.1’

A

a string - it has quotation marks

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

what type of object is 7.1

A

a float - it contains a decimal

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

what type of object is 7

A

an int- short for integer

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

how can you figure out whether something is outputting a string, an integer, a float, or something else

A

type(input)

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

how do you cast 2 as a float

A

float(2)

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

how do you cast 1.1 as a string

A

str(1.1)

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

what is important to remember about boolean operators

A

they must have capital letters (ie True and False)

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

does a false convert to a 0 or 1 integer

A

0

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

what is different between / for division and // for division

A

// will give you an integer, / will give you a float

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