Introduction to Python
Table of contents
a logo of Python language
Topic 1 : Getting Started with Python
Lesson 1 : Writing Code
"Python is one of the most popular and useful languages used to give instructions to
computers"
- Simple Syntax : print(" ")
print("welcome")
print("level up")
print("order shipped")
The print() instruction requires the use of parenthesis around the message
Make sure you use quotation marks around the text messages
Numbers don't require quotation marks
print(360)
print(3000)
print(13639027)
Lesson 2 : Memory & Variables
Computer programs use variables to remember important information
To create a variable , you need to give it a name
item = "bike"
Name is on left
Information is on right with both connected with an equal sign( \= )
item = "watch"
above code :
item is name of the variable
"watch" is value stored
both connected with \= sign
city = "London"
'you can think of a variable as a box that contains some information'
Lesson 3 : Text Data
"A large amount of information out there consist of text. A piece of text is called a string"
- Strings in Python need to be surrounded by quotation marks.
"The lords of the rings"
'hello world'
"we use quotation marks to tell Python that we are working with a piece of text data"
- strings can be stored in variables.
company = " apple "
name = 'Bill Gates'
status = "I am learning Python at this point of time"
book = 'The classical physics'
Note : In Python , both single ' and double " quotes can be used to define strings , but both should be matched as above example.
- The code in computer programs is made of statements. Statements are the instructions for the computer to follow.Real programs can contain thousands of statements.
book = " Harry Potter"
author = "J.K Rowling"
car = 'Tesla'
month = 'June'
above code example contains 4 statements
Question : What's the instruction below code is giving to the computer ?
country = 'Iceland'
answer : to create a variable
Lesson 4 : Numerical Data
"Numerical data is information that comes in the form of numbers "
- numerical values can be directly stored in variables.
population = 2500
attendence = 45
price = 30
- numerical data should not be in quotation marks
#below variable is right
points = 500
#can't write as given below
points = "500"
in above example numerical data with quotation marks will be treated as string**.**
you can send the number to the screen with the print() statement , just need to insert the numbers between the parentheses.
print(260)
print(100000)
print(1234)
We can perform math operations with numbers . Each print() instruction will add a value to the screen in a new line.
print(7 + 3)
print(10 - 5)
print(5 * 3)
print( 10 / 2)
Submission +
Subtraction -
Multiplication *
Division /
Lesson 5 : Working with Variables
" Variables are key to software development. They allow you store , lebel and play with data"
#Storing string in the variable
size = " medium"
phone = " iphone"
#Storing number in the variable
age = 34
price = 150
matches = 100
- You can access the value stored in a variable by calling its name.
#the console will print 150
price = 150
print(price)
#the screen will show 30
budget = 20
print(budget + 10)
#screen will show 15
price = 5
amount = 3
print(price* amount)
#screen will show 15
score = 7+8
print(score)
- You can update the value stored in a variable . The variable will forget the previously stored value .
price = 99
price = 100
print(price)
#console will display 100 not 99
- Updating the value of a variable is called Reassigning a variable
#example of Reassigning a variable
points = 35
points = 45
print(points) #console will print 45
name = "tom"
level = 14
print(name) #tom will be printed
level = level + 1
print(level) # 15 will be printed
"Thanks for Reading 😊😊😊"
“In this post, we explored Getting Started with Python in Python programming. In my upcoming posts, I will be diving deeper into other important topics such as
▶️ Going Deeper with Python
▶️ Working with Data
▶️ Control Flow
▶️ Working with Lists
▶️ Functions
Stay tuned for more informative and engaging content on Python programming!”🚨🚨🚨
Subscribe to my newsletter
Read articles from Aftab Ahmed directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Aftab Ahmed
Aftab Ahmed
Student pursuing BBA -Healthcare |Tech Enthusiast| Learning Python from scratch | #100Days of Code Challenge