Python Flashcards
What year was Python invented?
1991
Why Python?
-similar to English/Math
-support lots of frameworks/libraries
-easy to learn
What are 4 ways to use Python?
-Web development
-Artificial intelligence
-Machine learning
-Data analytics
What is a key advantage of Python?
Less code, speed to market
What does IDE stand for?
Integrated development environment
What 6 features does IDE Visual Code have?
-auto-completion
-debugging
-code syntax
-highlighting
-white space
-indentation helpers
What are 3 reasons for commenting on code?
-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
What are the 3 ways you can comment on code?
-single-line
-multi-line
-inline
What is an example of a single-line comment?
- # this is my comment
What is an example of multi-line comments?
- # this is my comment# and this too
What is an example of an online comment?
X = 5 # this is my comment
What is a variable?
-a value that can change, depending on conditions or on information passed to the program
Can variables be changed?
Yes
What is an important rule about naming variables?
Give meaningful names in context
What are two ways to name(write) variables?
-camelcase
-snakecase
What is camelcase?
myName
What is snakecase?
my_name
How do you delete a variable?
A = 10
del A
What is a data type?
An attribute associated with a piece of data that tells the computer how to interpret its value.
What are the 5 data types?
-numeric
-sequence
-dictionary
-boolean
-set
What are the 3 types of numeric data types?
-integer
-float
-complex
What is an integer?
-non fractional number.
10, -10
What is a float?
- a number with decimal places
10.5, 3.2
What is a complex numeric data type?
Real and imaginary numbers
A = 10 + 10j
What are the 3 types of sequence data types?
- strings
- lists
- tuples
What is a string?
Sequence of characters enclosed in single or double quotes
What is the abbreviation for string?
str
What are examples of strings?
‘John’
“This is a string”
Name = “John”
What are lists?
Sequence of one or more types
What brackets do lists use?
Square Brackets
What is an example of a list?
list = [4, “hello”, A, 3.2]
What is the abbreviation for lists?
list
What are tuples?
An ordered sequence of one or more types
What is a difference between lists and tuples?
Tuples are immutable.
Can not be changed or modified
What is a dictionary?
Store data in a key value object structure
What is the abbreviation for dictionary?
dict
What is an example of a dictionary?
ed = {‘a’:22, ‘b’:44.2}
What brackets do dictionaries use?
Curvy brackets
What is a Boolean?
True or False statement
What is the abbreviation for Boolean?
bool
What is a set?
An unordered and non-indexed collection of non-repeated values
How do you check a data type?
a = 10.0
print(type(a))
Class ‘float’
What are 2 ways that you can write strings?
-single line
-multi-line
What is an example of a single line string?
varA = “Hello World”
What is an example of a multi-line string?
varB = “this is too big\
to fit on\
a single line”
How do you access a character of a string?
name = “John”
print(name[2])
h
How do you check the length of a string?
len()
name = “John”
print(len[name]
What is concatenation?
Joining of separate strings
How do you concatenate?
a = “Hello”
b = “World”
print(a + b)
Hello World
What does == mean?
Equals
What does != mean?
Not equal
What does < mean?
Less than
What does > mean?
More than
What does <= mean?
Less than or equal too
What does >= mean?
Greater than or equal too