My Studies Following Angela Yu's Course. 100 different projects will be built.
All projects are available listed at the end of this Readme.
- Strings
- Integers
- Floats
- Booleans
- PRINT =
print()
- PRINT FORMATTED (f-Strings)=
print(f"I am {age} years old")
- INPUT =
input()
(Obs.: the input will always be a String) - LENGTH =
len()
- TO INT =
int()
- TO STR =
str()
- TO FLOAT =
float()
- TO BOOLEAN =
bool()
- COUNT -
count()
- Return the number of times the value appears in the list.
#Counts how many times '9' appears in the list
points = [1, 4, 2, 9, 7, 8, 9, 3, 1]
x = points.count(9)
- ROUND A NUMBER =
round(number, ndigits)
- CONVERT TO LOWERCASE =
.lower()
(Example:input().lower()
) - CONVERT FIRST LETTERS TO CAPITAL LETTERS =
.title()
(Example:input().title()
) - Lists -
fruits = [item1, item2]
- ADD ONE ITEM IN A LIST =
.append()
(Example:states_of_usa.append("New Jersey")
) - ADD SOME ITEMS IN A LIST =
.extend()
(Example:states_of_usa.extend(["Georgia","Connecticut"])
)- List x Array = A List is more flexible and can have multiple types of data (int, str, float, etc). An array is more restricted and can only have one type of data.
#Indentation is crucial in Python for conditionals
if condition:
do this
else:
do this
#Indentation is crucial in Python for conditionals
if condition:
do this
elif another condition:
do this
else:
do this
- FOR LOOPS - There are 2 types of 'for' loops: 'for' using lists and 'for' using range
- FOR LISTS
for item in list_of_items:
#do something
#for the 'item', we give a name for a single item
- RANGE -
range(a, b, c)
- Creates a range from 'a' to 'b' (obs.: NOT INCLUDING the last number 'b'). Has to be used in conjunction with another function.
- 'c' is optional. Is a "step" function that will jump characters from the number you input in.
- Example:
range(1, 10, 3)
- It will steps 3 by 3. Result will be:1, 4, 7, 10
- Example:
- FOR LOOP WITH RANGE
for number in range(a, b)
print(number)
- SUM -
sum()
- Get the sum from a List
- MAX -
max()
- Get the maximum value from a List
def
- Defining Functions
def my_function():
#Do this
#Then do this
#Finally do this
- Functions with Inputs
- In the example below
something
is the Parameter, and it's value inputted is Argument (the value of data)
- In the example below
def my_function(something):
#Do this with something
#Then do this
#Finally do this
- Functions with Multiple Inputs
def my_function(a, b, c):
#Do this with 'a'
#Then do this with 'b'
#Finally do this 'c'
- Functions with Outputs
- Functions which allows you to have an output once the function is completed.
def my_function():
result = 3 * 2
return result
- WHILE LOOP
while something_is_true:
#do something repeatedly
- FOR LOOP x WHILE LOOP:
- FOR LOOPS: Really good when you need to iterate over something and you need to do something with EACH THING that you're iterating over.
- WHILE: Good to just simply wants to carry out a functionality until a certain condition.
- While loops are more dangerous, due to possible Infinite Loops.
try
andexcept
-
try
- This is where you write the code that could potentially raise an exception. -
except
- If an error occurs in the try block, the program jumps here to handle the error instead of crashing. -
Example 1: Handling Division by Zero python
-
#Example 1: Handling Division by Zero
try:
result = 10 / 0 # This will cause a ZeroDivisionError
except ZeroDivisionError:
print("You can't divide by zero!")
- Example 2: Catching Multiple Exceptions You can handle different errors with multiple except blocks:
#Example 2: Catching Multiple Exceptions
try:
number = int("abc") # This will cause a ValueError
except ValueError:
print("That's not a valid number!")
except ZeroDivisionError:
print("You can't divide by zero!")
- Example 3: Generic Exception Handling
If you’re unsure which exception might occur, you can catch all exceptions with a generic except:
#Example 3: Generic Exception Handling
try:
risky_code()
except Exception as e:
print(f"An error occurred: {e}")
- ADDITION:
+
- ADDITION OF ACTUAL VALUE:
+=
- SUBTRACTION:
-
- SUBTRACTION OF ACTUAL VALUE:
-=
- MULTIPLICAÇÃO:
*
- DIVISÃO:
/
(sempre vai ser 'float') - DIVISÃO:
//
(remove todas as casas após a vírgulas, vira um 'int') - POTENCIAÇÃO:
**
- REMAINDER:
%
(Check the remainder, how many is remaining after that division) - MODULO EQUALS -
%=
- AND -
and
- OR -
or
- NOT -
not
Operator | Meaning |
---|---|
> | Greater Than |
< | Less Than |
>= | Greater than or Equal to |
<= | Less than or Equal to |
== | Equal to |
!= | Not Equal to |
- Structure - Key: Value
empty_dictionary = {}
random
- Randomisation- RANDOM CHOICE ON A LIST =
random.choice(list_name)
- RANDOM INTEGER =
random.randint(a, b)
Range from 'a' to 'b' - RANDOM FLOAT INTERVAL =
random.uniform(a, b)
Range from 'a' to 'b' - RANDOM FLOAT 0 TO 1 =
random.random()
Range from 0 to 1 - RANDOM SHUFFLE -
random.shuffle(list_name)
Shuffles the order of the list
- RANDOM CHOICE ON A LIST =
os
- Operational System- Clear terminal (example for Windows)
from os import system system("cls")
- Easy Debugger - Python Tutor
- Easy Debugger - Thonny
- ASCII Art Generator
- Another ASCII Art Generator
- Emojipedia
- PyPI - Python Package Index
- Band Name Generator
- Printing, Commenting, Debugging, String Manipulation and Variables
- Tip Calculator
- Data Types, Numbers, Operations, Type Conversion, f-string
- Treasure Island - Game
- Conditional Statements, Logical Operators, Code Blocks and Scope
- Rock-Paper-Scissors - Game
- Randomization and Python Lists
- Password Generator
- For Loops, Range and Code Block
- Escaping the Maze - Reeborg's World
- Functions, Code Blocks and While Loops
- Hangman Project
- Flow Chart Programming
- Caesar Cipher
- Functions with Inputs, Parameters and Arguments
- Blind Auction Program
- Dictionaries & Nesting
- Calculator App
- Functions with Outputs
- Blackjack Game
- Number Guessing Game
- Scope: Local Scope and Global Scope
- Debugging
- Higher or Lower
- Coffee Machine Project
- OOP Coffee Machine Project
- OOP - Object Oriented Programming