Python Flashcards

1
Q

What year was Python invented?

A

1991

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

Why Python?

A

-similar to English/Math
-support lots of frameworks/libraries
-easy to learn

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

What are 4 ways to use Python?

A

-Web development
-Artificial intelligence
-Machine learning
-Data analytics

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

What is a key advantage of Python?

A

Less code, speed to market

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

What does IDE stand for?

A

Integrated development environment

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

What 6 features does IDE Visual Code have?

A

-auto-completion
-debugging
-code syntax
-highlighting
-white space
-indentation helpers

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

What are 3 reasons for commenting on code?

A

-explain what code is intended to do
-let developers know code is depreciated
-add TO-DO comments for work to do at a later time

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

What are the 3 ways you can comment on code?

A

-single-line
-multi-line
-inline

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

What is an example of a single-line comment?

A
  • # this is my comment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an example of multi-line comments?

A
  • # this is my comment# and this too
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an example of an online comment?

A

X = 5 # this is my comment

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

What is a variable?

A

-a value that can change, depending on conditions or on information passed to the program

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

Can variables be changed?

A

Yes

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

What is an important rule about naming variables?

A

Give meaningful names in context

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

What are two ways to name(write) variables?

A

-camelcase
-snakecase

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

What is camelcase?

A

myName

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

What is snakecase?

A

my_name

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

How do you delete a variable?

A

A = 10

del A

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

What is a data type?

A

An attribute associated with a piece of data that tells the computer how to interpret its value.

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

What are the 5 data types?

A

-numeric
-sequence
-dictionary
-boolean
-set

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

What are the 3 types of numeric data types?

A

-integer
-float
-complex

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

What is an integer?

A

-non fractional number.
10, -10

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

What is a float?

A
  • a number with decimal places
    10.5, 3.2
24
Q

What is a complex numeric data type?

A

Real and imaginary numbers
A = 10 + 10j

25
Q

What are the 3 types of sequence data types?

A
  • strings
  • lists
  • tuples
26
Q

What is a string?

A

Sequence of characters enclosed in single or double quotes

27
Q

What is the abbreviation for string?

A

str

28
Q

What are examples of strings?

A

‘John’
“This is a string”
Name = “John”

29
Q

What are lists?

A

Sequence of one or more types

30
Q

What brackets do lists use?

A

Square Brackets

31
Q

What is an example of a list?

A

list = [4, “hello”, A, 3.2]

32
Q

What is the abbreviation for lists?

A

list

33
Q

What are tuples?

A

An ordered sequence of one or more types

34
Q

What is a difference between lists and tuples?

A

Tuples are immutable.
Can not be changed or modified

35
Q

What is a dictionary?

A

Store data in a key value object structure

36
Q

What is the abbreviation for dictionary?

A

dict

37
Q

What is an example of a dictionary?

A

ed = {‘a’:22, ‘b’:44.2}

38
Q

What brackets do dictionaries use?

A

Curvy brackets

39
Q

What is a Boolean?

A

True or False statement

40
Q

What is the abbreviation for Boolean?

A

bool

41
Q

What is a set?

A

An unordered and non-indexed collection of non-repeated values

42
Q

How do you check a data type?

A

a = 10.0

print(type(a))

Class ‘float’

43
Q

What are 2 ways that you can write strings?

A

-single line
-multi-line

44
Q

What is an example of a single line string?

A

varA = “Hello World”

45
Q

What is an example of a multi-line string?

A

varB = “this is too big\
to fit on\
a single line”

46
Q

How do you access a character of a string?

A

name = “John”

print(name[2])

h

47
Q

How do you check the length of a string?

A

len()

name = “John”
print(len[name]

48
Q

What is concatenation?

A

Joining of separate strings

49
Q

How do you concatenate?

A

a = “Hello”
b = “World”

print(a + b)

Hello World

50
Q

What does == mean?

A

Equals

51
Q

What does != mean?

A

Not equal

52
Q

What does < mean?

A

Less than

53
Q

What does > mean?

A

More than

54
Q

What does <= mean?

A

Less than or equal too

55
Q

What does >= mean?

A

Greater than or equal too