Module 1 Python Basics Flashcards
- Types - Expressions and Variables - String Operations
What scientific computing libraries does Python have?
Pandas, NumPy, SciPy, and Matplotlib
What scientific AI libraries does Python have?
Keras, Scikit-learn, Tensorflow, Pytorch
Python can be used for Natural Language Processing (NLP), using the Natural Language Toolkit (NLTK) Yes or No?
Yes
What is an Int?
A whole number (no decimals)
What is a float?
A real number (Anything between integers ex: 0.8 is between 0 and 1)
Changing Expression Types (Type Casting)
- You can convert (cast) an int to a float
- If the string contains an integer value you can convert it to an integer
- If we convert a string that contains a non-integer to an integer value, we get an error
- You can convert an int to a string
- You can convert a float to a string
Data Types: Boolean
- Booleans can be True and False (remember to use uppercase T and F)
- Using the type command on a Boolean value we obtain the term bool (example: type(True): bool
- If we cast a Boolean True to an interger or float we obtain the number 1
- If we cast a Boolean False to an integer or float we obtain the number 0
- If we cast a 1 to a boolean bool(1)we get a true
- If we cast a 0 to a boolean bool(0) we get a false
What is the type of the result of 6/2?
Float
What is the type of the result of 6//2?
Int
- The double slashes stand for integer division
Expressions and Variables
.
Expressions
Expressions describe a type of operation that computers perform.
Expressions are also…..
Operations that python performs
Operands
Numbers in a mathematical equation
What are the math symbols called?
operators
Variables
- Can be used to store values
- Ex: x = 1
- The colon denotes the value of the variable
So now x:1 will give you 1
- We can assign a new value to the colon using the same assignment operator. The old value will be overwritten with the new value