Python Flashcards
What is an IDE?
Integrated Development Environment. You can use any text editor to write code. However, most integrated development environments (IDEs) include functionality that goes beyond text editing. They provide a central interface for common developer tools, making the software development process much more efficient. Developers can start programming new applications quickly instead of manually integrating and configuring different software.
What are variables and how do you define them?
Variables are containers for storing data values. Separate space between words with underscore(“_”). Structured: variable_name = variable_value. Basically similar to JavaScript, but without variable declaration keywords like var, const, and let.
What are some of the data types in Python?
Strings, numbers, boolean, tuples
What are strings?
Text encapsulated within quotes(“”). Use \n to start a new line within a quote. Use " to print a quotation mark within a string. You can use string functions (len, index, upper, lower…etc)
What is concatnation?
Joining two or more string together.
What are some number functions?
str(): convert number to string. Used to concatenate string with numbers.
abs(): convert number to an absolute value.
pow(): pass two parameters, takes the power of the second parameter to the first one.
max(): get the max number from the parameters.
min(): get the min number from the parameters.
round(): round the number
How can you import other number functions?
from math import *. Import from the math module.
How to get input from user?
using input().
ex: name = input(“Enter your name: “)
age = input(“Enter your age: “)
print(“Hello “ + name + “! You are “ + age)
What is the default data type when getting input from user?
string. If you want to work with numbers, you need to convert user input into number. ex: int(), float()
What are lists? How do you define them?
a set of data.
ex: friends = [“Kevin”, “Karen”, “Jim”]
How do you access the last item on the list?
list[-1]
How do you access all of the list items after index 1?
list[1:]
How do you access second and third item on the list?
list[1:3]. The last number does not get included on the result
What are some of the List Functions?
extend(): allows you to add another list to a list.
append(): allows you to add an item to the end of the list.
insert(): allows you to add in a specific index. takes two parameters (index_number, “add_item”)
remove(): allows you to remove an item from the list
clear(): removes every element from the list
pop(): removes last element from the list
count(): gives you the number of times the element occurred in the list
index(): gives you the index number in the list where the element appears
sort(): sorts the list in ascending order
reverse(): reverse the list items
copy(): copy the list
What is a tuple?
similar to lists but wrap elements in () and tuples are immutable. you can make a list of tuples
How to create functions? How do you call functions?
def function_name():
function_name()
What is if statement?
evaluates a condition. If evaluated True, the code inside the body of it is executed. If not, the code inside the body of if is skipped.
what is get in python?
allows you to access values by accessing the key. You can also put in default action if the key is not found.