Firstly, we need to download Visual Studio Code. Visual Studio Code is a streamlined code editor with support for development operations like debugging, task running, and version control. Go to the website: https://code.visualstudio.com/Download For the video about downloading: https://youtu.be/Dnw27nTX66o?t=22
Secondly, we need to download Python. Python is an interpreted, object-oriented, high-level programming language with dynamic semantics developed by Guido van Rossum. We download it to use this software language on our device. Go to the website: https://www.python.org/downloads/
Last step: install python extension to VSCode. This allowed us to write, run and debug python commands on VSCode. To do this step, you can watch the video or follow the images. Video link: www.youtube.com
Step 2: Write Python to the Search Box
Step 3: Install the Python Extension
In this section, I will write and show some code lines one by one. You will see examples and explanations and if you want to get the code, you can reach them above.
Step 1: Click the Open Folder Button
Step 2: Create a Folder
Step 3: Click the button
Step 4: Write a name for file and end it with ".py" (example_name.py)
Step 5: Sit back and realize you're ready! 😁
Uses to output to the screen. Usage:
print("Can you hear me?")
This will write Can you hear me? to the terminal
It allows us to use it in the program by entering data from the terminal
input("Write your name: ")
This will write Write your name: and will wait until you write anything
It allows us to create condition block
if 5 > 2:
print("This is true!")
This will write This is true! because if condition is right (As we know, 5 is bigger than 2). So how do we do it if it's wrong?
It allows us to create condition block
if 2 > 5:
print("This is true!")
else:
print("This isn't true!")
This will write This isn't true! because if condition isn't right (As we know, 2 isn't bigger than 5). So how do we do it if it's equal?
It allows us to create condition block with different possibilities
if 2 > 2:
print("This is true!")
elif 2 == 2:
print("They are equal")
else:
print("This isn't true!")
This will write They are equal because if condition isn't right and elif is right. (As we know, 2 equal 2 😁). So how do we do cheack them? For example we used "==" in our "elif" section. Before talk about them, I need to show one more thing.
It allows us to create condition block with more different possibilities
if 2 > 2:
print("This is true!")
elif 2 == 2:
print("They are equal")
.
.
.
elif 2 != 2:
print("They aren't equal")
else:
print("This isn't true!")
Explanation
This will write They aren't equal because if-second elif condition isn't right and first elif is right. We used "!=" in our "elif" section. As the other example, we can check some conditions. These "==" and "!=" some examples of what we use. Until now, you learned the print something to the screen, you learned to use input and you see the if-elif-else condition blocks. To learn and understand these blocks too, we need to learn something more 😄
In this sections, you will see explanations about data types. Thus you will understand variables and data types. After this sections, you will see explanations about variables. Shortly, we use them to store or use datas in our program or code.
This data type is using for string datas. For example, if you want to add your name or any kind of string data your variable will be
strdata.
"Earth"is a string(str) data.
This data type is using for integer datas. For example, if you want to use your age in your program it will be
intdata.
13is a integer(int) data.
This data type is using for decimal number datas. For example, if you want to use temperature in your program this data will be
float.
303.1is a float data.
This data type is using for understanding something is
TrueorFalse. We generally use them with loops.
This data type is using for collecting datas under a list. You can think it like your "shopping list", that's mean your "shopping list" is a
listdata. In python we use "[" and "]" for define them.
["book","cd","food","water"]
If you want to add line which won't use by program, you can write them with "#". It's name is comment line because developers use them for adding note their programs. But if your comment will be longer than 4-5 lines you have another option to make them comment line, It's "
" "" . Let's look at the example below.
print("Where I am?") # This is comment line too but if I do like this, my print command will work but as the other this part won't run by program
```And this is the comment block in PythonYou can write a lot of lines into this```
As I told before, we use variables to store or use datas in our program or code. Let's see how we use them.
We can define variables when we write the code.
name = "Apple" # str (String)
myNumber = 5 # int (Integer)
your_ number = 0.2 # float (Float)
ourList = ["apple","orange","grape"] # list (List)
We don't have to define variable with their values. Let's get values from user.
name = input("What is your name? >")
Explanation
But there is a difference. If user write there 6, this data won't be string. Until you write an answer to your input command, "name" will be "NoneType". You can think that's undefinied. But when you write and hit the enter, it will be changed.
We can use data came from user. In this example we will use
fstring. We can use our variables in the texts we wrote with this string type. Looks like thatprint(f"{variable_name}")
name = input("What is your name? >")
print(f"My name is {name}") # Output will be "My name is (your input)"
Explanation
If you want to print your name here, you have to write your variable which gets your name.
We can print our datas by their variable.
myName = "Apple"
yourName = input("What is your name? > ")
print(myName) # Apple writes.
print(yourName) # It will write your input
In this sections, you will see some common operations but they won't be all of them. For more look at the table and go for full document.
We use these operator for check the values or datas are equal or not and returns
TrueorFalse. Let's learn with the examples. In this example I will use with print but of course, you can use different ways.
x = 5
y = 10
print(x == y) # Prints "False" (== -> Are they equal?)
print(x != y) # Prints "True" (!= -> Are they not equal?)
We use these operator for basic mathematical calculations.
x = 47
y = 38
print(x + y) # Prints "85"
print(x - y) # Prints "9"
print(x / y) # Prints "1.236842105263158"
print(x * y) # Prints "1786"
We use these to returns
TrueorFalse. They control the values like==and!=.
x = 50
y = 30
print(x > y) # Prints "True"
print(x < y) # Prints "False"
We use these operator for creating more complex conditions.
x = 50
y = 30
print(x > y and x == 50) # Prints "True". Because x > y is true and x == 50 returns true too. Then the result is true.
print(x < y or y == 30) # Prints "True". Because y = 30. In "or" operation, just one true enough for returning true.
Explanation
print(x > y and x == 50) # Prints "True". Because x > y is true and x == 50 returns true too. Then the result is true.
print(x < y or y == 30) # Prints "True". Because y = 30. In "or" operation, just one true enough for returning true.
Click on the Image to go to the source.
In this section, we will learn about loops. After this section, you will be ready for examples and more!
It's our the first loop type.
# for {variable name for each element} in {element's resource}:
# {we can do anything we want}
list = ["book","cd","food","water"]
for name in list:
print(f"This is {name}")
Explanation
This loop will run the print command for four times because our list have four element and name variable will be write different for each tour.
This is book
This is cd
This is food
This is water
It's our the second loop type.
# while ({condition}): # if the condition returns "True", loop will start and
# {we can do anything we want}
a = 10
while (a > 5):
print(f"A euals {a}")
Explanation
If you do like this, you code will run until you close it or forever :D To avoid this problems and handle the loops better we will learn these break, continue.
a = 10
b = 0
while (a > 5):
print(f"A euals {a}")
b = b + 1 # b will increase one each tour
if b == 5:
break # loop will end on this line
else:
continue # loop will continue when the b isn't equal 5
# In this loop, when the name equals to "food", loop will end
list = ["book","cd","food","water"]
for name in list:
if name == "food":
break
else:
continue
We will learn the data types and their conversions.
This command helps us to understand the variables types. Let's see in an example.
name = "Alice"
age1 = "18"
age2 = 18
age3 = 18.5
names = ["Alice", "Bob", "Larry"]
tutorial_is_good = True
print(type(name)) # name = "Alice" -> <class 'str'>
print(type(age1)) # age1 = "18" -> <class 'str'>
print(type(age2)) # age2 = 18 -> <class 'int'>
print(type(age3)) # age3 = 18.5 -> <class 'float'>
print(type(names)) # names = ["Alice", "Bob", "Larry"] -> <class 'list'>
print(type(tutorial_is_good)) # tutorial_is_good = True -> <class 'bool'>
# Tip
print(name + age1) # Works because we can collect str types
print(name + " " + age1) # Works because we can collect str types
printf(name + age2) # Doesn't Work we can't collect str and int types
print(name + " " + age2) # Doesn't Work we can't collect str and int types
str()
int()
float()
bool()
name = "Alice"
age1 = "18"
age2 = 18
age3 = 18.5
names = ["Alice", "Bob", "Larry"]
tutorial_is_good = True
print(name + age1) # Works because we can collect str types
print(name + " " + age1) # Works because we can collect str types
printf(name + str(age2)) # Doesn't Work we made the age2's type str
print(name + " " + str(age2)) # Doesn't Work we made the age2's type str
a = "True"
print(type(a))
print(type(bool(a)))
name = input("Please write your name: ")
print(f"\nHi {name}, It's nice to see you. Did you drink enough water today? ")
water = input("? > ")
print(f"It's important {name}, Studies show that an adult woman should drink 2.7 liters of fluid per day, and a man 3.7 liters. But softwares not ^-^")
print("This program write a automatic self introduction text.\nLet's start!")
name = input("What is your name? > ")
surname = input("\nWhat is your surname? > ")
age = input("\nHow old are you? > ")
country = input("\nWhere do you live? > ")
job = input("\n")
note = input("\n")
print("\n\nHi! It's {name} {surname}. I am {age}. I live in {country} and I do {job} for living. Finally, {note}.")
print("This is a grade checker.\nYour first test has an impact rate of 40%, your second test has an impact rate of 60%.\nWrite your scores and see your result.\nIf you have lower than 40, you will be unsuccesful.\n(Grades must be between 0-100)\n")
firstTest = input("Your first test score: ")
secondTest = input("Your second test score: ")
result = (firstTest*40)/100 + (secondTest*60)/100
if result > 40:
print("\nYou passed the class\n")
else:
print("\nYou didn't pass the class\n")
print("This is a grade checker.\nYour first test has an impact rate of 40%, your second test has an impact rate of 60%.\nWrite your scores and see your result.\nIf you have lower than 40, you will be unsuccesful.\n(Grades must be between 0-100)\nAt this program, your grade will handle different")
firstTest = input("Your first test score: ")
secondTest = input("Your second test score: ")
result = (firstTest*40)/100 + (secondTest*60)/100
if result >= 90:
print("\nYour grade is equal or more than 90\n")
elif result < 90:
print("\nYour grade is lower than 90\n")
else:
print("\nAn error occured\n")
print("This is a grade checker.\nYour first test has an impact rate of 40%, your second test has an impact rate of 60%.\nWrite your scores and see your result.\nIf you have lower than 40, you will be unsuccesful.\n(Grades must be between 0-100)\nAt this program, your grade will handle different")
firstTest = input("Your first test score: ")
secondTest = input("Your second test score: ")
result = (firstTest*40)/100 + (secondTest*60)/100
if result >= 90:
print("\nYour grade is equal or more than 90\n")
elif result < 90:
if result >= 70:
print("\nYour grade is equal or more than 70\n")
elif result < 70:
if result <= 50:
print("\nYour grade is lower than 70\n")
elif result < 50:
print("\nYour grade is equal or more than 50\n")
else:
print("\nAn error occured\n")
print("This is a grade checker.\nYour first test has an impact rate of 40%, your second test has an impact rate of 60%.\nWrite your scores and see your result.\nIf you have lower than 40, you will be unsuccesful.\n(Grades must be between 0-100)\nAt this program, your grade will handle different")
firstTest = input("Your first test score: ")
secondTest = input("Your second test score: ")
result = (firstTest*40)/100 + (secondTest*60)/100
if result >= 90 and result < 90:
print("\nYour grade is equal or more than 90\n")
elif result >= 70 and result < 70:
print("\nYour grade is equal or more than 70\n")
elif result <= 50:
print("\nYour grade is lower than 50\n")
else:
print("\nAn error occured\n")
You can send me your questions or examples in comment, maybe I can add them to the tutorial. Thank you for your interest. To improve your code, you can use the "Comment" section. Don't worry and don't hesitate, we all trying to improve ourselves ^-^




