These are my notes from the Udacity Python Course which I did as part of the Bertelsmann data science scholarship. This course covers basic Python and several Data Analysis packages of Python.
Python Basics
- Python is case sensitive
- Variables can’t start with a number. They can’t have space. You can’t use reserved words like False, continue, if, etc too.
- Method behaves like a function but the methods are called using a dot notation
- There are two types of errors:Exceptions, Syntax
An Exception is a problem that occurs when the code is running, but a ‘Syntax Error’ is a problem detected when Python checks the code before it runs it.
DATA TYPES & OPERATORS
- Operators: Arithmetic, Assignment, Comparison, Logical, Membership, Identity
- Data Types: Integers, Floats, Booleans, Strings, Lists, Tuples, Sets, Dictionaries
======== List of operators
- Assignment Operators ( = , +=, -=)
- Comparison Operators (<, >, <=, >=, ==, !=)
Logical Operators (and, or, not)
Numeric Values: 2 data types - int & float You can check the type by using the type function:
print(type(633))
Converting a fraction to int will remove the decimal part without rounding it.
x = int(4.7) # x is now an integer 4 y = float(4) # y is now a float of 4.0
Because the float, or approximation, for 0.1 is actually slightly more than 0.1, when we add several of them together we can see the difference between the mathematically correct answer and the one that Python creates.