Skip to content

Commit 5773599

Browse files
committed
Python Crash Course init Commit
0 parents  commit 5773599

File tree

75 files changed

+2200
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2200
-0
lines changed

01_variables/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Variables
2+
## Variables helps us to store key&value information that we would like to refer to its value throughout the program
3+
```python
4+
name = "Michael"
5+
age = 30
6+
7+
print(name, "is my name")
8+
print(name, "is", age, "years old")
9+
print(name, "likes to eat pizza")
10+
print("This man's name is", name)
11+
12+
13+
14+
```
15+
## Exercise:
16+
17+
### Is there a way that you can create more than one variable in one line of code ? Worth to search on web if this could be done!
18+
19+
### Answer:
20+
```python
21+
a, b, c = 1,2,3 # a will receive 1, b will receive 2, c will receive 3
22+
#More examples:
23+
print(a)
24+
print(b)
25+
print(c)
26+
27+
name, age = "Jim", 25
28+
print(name)
29+
print(age)
30+
```

01_variables/code.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#Variables
2+
3+
#Variables helps us to store key&value information that we would like to refer to its value throughout the program
4+
5+
6+
name = "Michael"
7+
age = 30
8+
9+
print(name, "is my name")
10+
print(name, "is", age, "years old")
11+
print(name, "likes to eat pizza")
12+
print("This man's name is", name)
13+
14+

02_types_and_conversions/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Types and Conversions
2+
## We can divide in any programming language some variable types into categories
3+
```python
4+
#All types:
5+
name = "John" #Strings - Characters that we want to create/store variables
6+
age = 30 #Integers - Numbers without decimal point
7+
temperature = 90.5 #Floating Numbers / Floats - Numbers with decimal point
8+
is_raining = False #Booleans - Describes a situation - True or False
9+
10+
#str() - Will convert to string
11+
#int() - Will convert to integers
12+
#float() - Will convert to floating numbers
13+
#bool() - Will convert to booleans
14+
15+
#Temperature average program:
16+
temperature1 = 95.5
17+
temperature2 = 94.5
18+
average = (temperature1 + temperature2) / 2
19+
print(int(average))
20+
21+
#Concatenate digits program:
22+
digit_one = 1
23+
digit_two = 2
24+
print(str(digit_one) + str(digit_two))
25+
26+
```

02_types_and_conversions/code.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#Types and Conversions
2+
3+
#We can divide in any programming language some variable types into categories
4+
5+
6+
#All types:
7+
name = "John" #Strings - Characters that we want to create/store variables
8+
age = 30 #Integers - Numbers without decimal point
9+
temperature = 90.5 #Floating Numbers / Floats - Numbers with decimal point
10+
is_raining = False #Booleans - Describes a situation - True or False
11+
12+
#str() - Will convert to string
13+
#int() - Will convert to integers
14+
#float() - Will convert to floating numbers
15+
#bool() - Will convert to booleans
16+
17+
#Temperature average program:
18+
temperature1 = 95.5
19+
temperature2 = 94.5
20+
average = (temperature1 + temperature2) / 2
21+
print(int(average))
22+
23+
#Concatenate digits program:
24+
digit_one = 1
25+
digit_two = 2
26+
print(str(digit_one) + str(digit_two))

03_input/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Input built in function
2+
## Input built-in function allows to receive input from the user while the programs runs. Program won't resume till you put your input
3+
```python
4+
#We always want to assign the input built-in function to a variable
5+
answer = input("How is the weather today")
6+
print("The weather today is ", answer)
7+
8+
#You can force your inputs to receive specific types of variables:
9+
current_year = 2021
10+
answer = int(input("What is your age?")) # We could use any built-in conversion function here we'd like
11+
print("Your year of birth is", current_year - answer)
12+
13+
14+
15+
```
16+
## Exercise:
17+
18+
### Write a program that will receive three inputs, grade_one, grade_two, grade_three. Try to write a program that will print the average of the received three grades.
19+
20+
### Answer:
21+
```python
22+
#We need to force each input to be integers (float would also work)
23+
grade_one = int(input("What is the first grade?"))
24+
grade_two = int(input("What is the second grade?"))
25+
grade_three = int(input("What is the third grade?"))
26+
27+
avg = (grade_one + grade_two + grade_three) / 3
28+
print("Average is:", avg)
29+
```

03_input/code.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#Input built in function
2+
3+
#Input built-in function allows to receive input from the user while the programs runs. Program won't resume till you put your input
4+
5+
6+
#We always want to assign the input built-in function to a variable
7+
answer = input("How is the weather today")
8+
print("The weather today is ", answer)
9+
10+
#You can force your inputs to receive specific types of variables:
11+
current_year = 2021
12+
answer = int(input("What is your age?")) # We could use any built-in conversion function here we'd like
13+
print("Your year of birth is", current_year - answer)
14+
15+

04_formatted_strings/code.py

1.77 KB
Binary file not shown.

05_methods/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Methods
2+
## Different variable types are going to have their unique methods
3+
```python
4+
#This is the name of our person:
5+
name = "John doe"
6+
7+
#Say that we want this person to have the name spelled as it supposed to be: John Doe
8+
#We can launch this method:
9+
10+
print(name.title()) # Will print John Doe
11+
12+
#We might think that once you launch this method on the variable, it will override it for the rest of the program
13+
14+
#BUT:
15+
#Lets write this program now:
16+
17+
name_two = "John doe"
18+
name_two.title()
19+
print(name_two) # This line will STILL show: John doe
20+
21+
#Reason:
22+
#Not all the methods out there, will affect the value of the variable that you apply the method on.
23+
24+
#To really override the value itself, we can launch this:
25+
26+
name_three = 'John doe'
27+
name_three = name_three.title()
28+
print(name_three) # This line will print John Doe
29+
```

05_methods/code.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#Methods
2+
3+
#Different variable types are going to have their unique methods
4+
5+
6+
#This is the name of our person:
7+
name = "John doe"
8+
9+
#Say that we want this person to have the name spelled as it supposed to be: John Doe
10+
#We can launch this method:
11+
12+
print(name.title()) # Will print John Doe
13+
14+
#We might think that once you launch this method on the variable, it will override it for the rest of the program
15+
16+
#BUT:
17+
#Lets write this program now:
18+
19+
name_two = "John doe"
20+
name_two.title()
21+
print(name_two) # This line will STILL show: John doe
22+
23+
#Reason:
24+
#Not all the methods out there, will affect the value of the variable that you apply the method on.
25+
26+
#To really override the value itself, we can launch this:
27+
28+
name_three = 'John doe'
29+
name_three = name_three.title()
30+
print(name_three) # This line will print John Doe

06_string_methods/README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)