SlideShare a Scribd company logo
Introduction to
Python
Welcome
Congratulations for deciding to participate
in a 7 days of Introduction to Python
Course.
In this course you will learn the basics of
programming using Python.
Course Introduction
This course is designed for beginners and
intermediate who want to learn python
programming language.
In this course the topics are broken down
into 7 days, where each day contains several
topics with easy-to-understand
explanations, real-world examples, many
hands on exercises and a final project.
Why Python?
Python is a programming language which is
very close to human language and because
of that it is easy to learn and use.
Python is used by various industries and
companies (including Google).
It has been used to develop web
applications, desktop applications, system
administration, and machine learning
libraries.
Installing Python
 To run a python script you need to install python.
Let's download python from
https://www.python.org/.
Installing VS Code
 Visual Studio Code is a code editor (much like
any other editor like Notepad) helpful in writing
and editing codes.
 We download it from here
https://code.visualstudio.com/
Basic Data-types
 Boolean
A boolean data type is either a True or False value. T and F
should be always uppercase.
 Integers (default for numbers)
z = 5
 Floats
x = 3.1416
 Complex Numbers
x = 1+2j
Basic Data-types
 Strings
• Can use “ ” or ‘ ’ to specify strings
• a = “Nepal”
• b = ‘Kantipur Engineering College’
• “abc” == ‘abc’
• Use “ ” if ’ already in string eg: “matt’s”
• Use triple double-quotes for multi-line strings or strings
than contain both ‘ and “ inside of them:
“““a‘b“c”””
Checking Data Types
 To check the data type of certain data/variable we
use the type function.
>>> type(15)
<class ‘int’>
>>> type(3.14)
<class ‘float’>
>>> type(1+2j)
<class ‘complex’>
>>> str = “Hello World”
>>> type(str)
<class ‘string’>
Naming Rules
 Names are case sensitive and cannot start with a
number.
 They can contain letters, numbers, and
underscores.
 bob Bob _bob _2_bob_ bob_2 BoB
 There are some reserved words:
and, assert, break, class, continue, def, del, elif, else,
except, exec, finally, for, from, global, if, import, in, is,
lambda, not, or, pass, print, raise, return, try, while
 Can’t do this
• for = 12 #for is a reserved word
Assignment
 Assign value to variables
>>> x = 2
 You can assign to multiple names at the same time
>>> x, y = 2, 3
>>> x
2
>>> y
3
 This makes it easy to swap values
>>> x, y = y, x
 Assignments can be chained
>>> a = b = x = 2
Mathematical Operators
Mathematical Operators
 Exercise: Find an Euclidian distance between (2, 3) and
(10, 8)
Mathematical Operators
 Exercise: For a given temperature in celsius stored in
variable ‘t_c’, get the Fahrenheit temperature in ‘t_f’ and
display result.
• Let t_c = 100
• ans = 212
Checking Data Types
 Exercise: What would be the data-type of?
>>> a = 4/3
>>> type(a)
>>> n = 4//3
>>> type(a)
>>> num = ‘2080’
>>> type(num)
Type Casting
 Converting one data type to another data type.
 We use int(), float(), str()
>> # float to int
>> gravity = 9.81
>> print(int(gravity))
Type Casting
 When we do arithmetic operations string numbers
should be first converted to int or float otherwise it
will return an error.
>> #str to int or float
>> num_str = '10.6‘
>> print('num_int', int(num_str))
>> print('num_float', float(num_str))
Comparison Operators
Comparison Operators
 In programming we compare values, we use
comparison operators to compare two values. We
check if a value is greater or less or equal to other
value.
>> 2 == 2
>> 3.14 == 3.1416
>> print(123 == ‘123’)
>> print(123 == int(‘123’))
>> a = ‘mango’
>> b = ‘orange’
>> a == b
>> a < b What does this show?
Logical Operators
Logical Operators
 Logical operators are used to combine conditional
statements:
>> 2 == 2 and 2 < 4
True
>> print()
>>
>> a = ‘mango’
>> b = ‘orange’
>> a == b
>> a < b What does this show?
Conditionals
 In python the key word if is used to check if a
condition is true and to execute the block code.
Remember the indentation after the colon.
a = 10
if a > 3:
print(a, “is greater than 3”)
 if else
a = 3
if a > 0:
print(a, “is positive number”)
else:
print(a, “is negative”)
Conditionals
 if elif else
a = 3
if a > 0:
print(a, “is positive number”)
elif a < 0:
print(a, “is negative number”)
else:
print(a, “is zero”)
Operators and Conditionals
 Exercise:
 How do you check if a number is between 5 and 10
inclusive?
Note: Use if statement here
>>> if condition_1 and condition_2:
... choice_1
>>> else:
... choice_2
>>>
Operators and Conditionals
 Exercise:
 How do you check if a number is even or not using
python?
Note: Use if statement here
>>> if condition:
... choice_1
>>> else:
... choice_2
>>>
Program for the Day
Calculate Electricity Bill (15A)
KWh Minimum Charge Charge per KWh
0 to 20 50 4.00
21 to 30 75 6.50
31 to 50 75 8.00
51 to 100 100 9.50
101 to 250 125 9.50
250 above 175 11
Ans: 2330 for 250 units
Loops
 In programming we also do lots of repetitive tasks. In order
to handle repetitive task programming languages use loops.
Python programming language also provides the following
types of two loops:
• while loop
• for loop
While Loop
count = 0
while count < 5:
print(count)
count = count + 1 #prints from 0 to 4
for Loop
# syntax
for iterator in range(start, end, step):
#loop statements
for i in range(1,10,1):
print(i)
for Loop
num_list = [1,2,3,4,5]
for num in num_list:
print(num)
it_companies = ['Facebook', 'Google', 'Microsoft',
'Apple', 'IBM', 'Oracle',
‘Amazon‘]
for company in it_companies:
print(company)
Program for the Day
Student Grading SEE and NEB
Program for the Day
Student Grading SEE and NEB
 For a given students’ mark in percentage, display
letter grade for each student.
marks = 90
Your code should display “Outstanding”
Program for the Day
Student Grading SEE and NEB
 For a list of students’ marks in percentage, display
letter grade for each student.
marks = [95, 42, 78, 45, 89, 90]
Use for loop

More Related Content

PPTX
Python Lecture 2
Inzamam Baig
 
PPTX
lecture 2.pptx
Anonymous9etQKwW
 
PPTX
Introduction to learn and Python Interpreter
Alamelu
 
PDF
python notes.pdf
RohitSindhu10
 
PDF
python 34💭.pdf
AkashdeepBhattacharj1
 
PDF
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
PPTX
Review Python
ManishTiwari326
 
PPTX
made it easy: python quick reference for beginners
SumanMadan4
 
Python Lecture 2
Inzamam Baig
 
lecture 2.pptx
Anonymous9etQKwW
 
Introduction to learn and Python Interpreter
Alamelu
 
python notes.pdf
RohitSindhu10
 
python 34💭.pdf
AkashdeepBhattacharj1
 
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
Review Python
ManishTiwari326
 
made it easy: python quick reference for beginners
SumanMadan4
 

Similar to introduction to python in english presentation file (20)

PPTX
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
PDF
Python Training Course in Chandigarh(Mohali)
ExcellenceAcadmy
 
PDF
Python Training in Chandigarh(Mohali)
ExcellenceAcadmy
 
PPTX
Introduction To Python.pptx
Anum Zehra
 
PPTX
Python programing
hamzagame
 
PPTX
Python programming
Ashwin Kumar Ramasamy
 
PDF
TOPIC-2-Expression Variable Assignment Statement.pdf
EjazAlam23
 
PPT
Python Control structures
Siddique Ibrahim
 
PPTX
Review of C programming language.pptx...
SthitaprajnaLenka1
 
PPT
Control structures pyhton
Prakash Jayaraman
 
PPTX
Chapter 2-Python and control flow statement.pptx
atharvdeshpande20
 
PDF
Basic Concepts in Python
Sumit Satam
 
PPTX
Keep it Stupidly Simple Introduce Python
SushJalai
 
PPTX
Welcome to python workshop
Mukul Kirti Verma
 
PPTX
Python_Haegl.powerpoint presentation. tx
vishwanathgoudapatil1
 
PPTX
Python
Aashish Jain
 
PPTX
PPT_1_9102501a-a7a1-493e-818f-cf699918bbf6.pptx
myatminsoe180
 
PDF
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
PPTX
03 and 04 .Operators, Expressions, working with the console and conditional s...
Intro C# Book
 
PPTX
Python knowledge ,......................
sabith777a
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Python Training Course in Chandigarh(Mohali)
ExcellenceAcadmy
 
Python Training in Chandigarh(Mohali)
ExcellenceAcadmy
 
Introduction To Python.pptx
Anum Zehra
 
Python programing
hamzagame
 
Python programming
Ashwin Kumar Ramasamy
 
TOPIC-2-Expression Variable Assignment Statement.pdf
EjazAlam23
 
Python Control structures
Siddique Ibrahim
 
Review of C programming language.pptx...
SthitaprajnaLenka1
 
Control structures pyhton
Prakash Jayaraman
 
Chapter 2-Python and control flow statement.pptx
atharvdeshpande20
 
Basic Concepts in Python
Sumit Satam
 
Keep it Stupidly Simple Introduce Python
SushJalai
 
Welcome to python workshop
Mukul Kirti Verma
 
Python_Haegl.powerpoint presentation. tx
vishwanathgoudapatil1
 
Python
Aashish Jain
 
PPT_1_9102501a-a7a1-493e-818f-cf699918bbf6.pptx
myatminsoe180
 
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
Intro C# Book
 
Python knowledge ,......................
sabith777a
 
Ad

More from RujanTimsina1 (14)

PPT
Solar Radiation by Rujan Timsina EEC.ppt
RujanTimsina1
 
PPTX
Energy scenario and crisis in nepal by Rujan Timsina , part -1.pptx
RujanTimsina1
 
PPTX
Energy scenario and crisis in nepal, Rujan Timsina.pptx
RujanTimsina1
 
PPT
Lecture 3 Biomass energy...............ppt
RujanTimsina1
 
PPTX
world energy sources by rujan timsina.pptx
RujanTimsina1
 
PPT
RT bio mass or bio energy presentation .ppt
RujanTimsina1
 
PPTX
Fuel cell by Rujan Timsina, ioe, tu .pptx
RujanTimsina1
 
PPTX
energy scenario in the context of nepal.pptx
RujanTimsina1
 
PPTX
Thermodynamics Lab manual for students.pptx
RujanTimsina1
 
PPTX
Introduction to Energy Engineering Lab manual.pptx
RujanTimsina1
 
PDF
00 Introduction to theory of machine.pdf
RujanTimsina1
 
PPTX
Fossil fuel RT rujan timsina .pptx
RujanTimsina1
 
PPTX
Zero Energy Buildings _ Rujan Timsina-.pptx
RujanTimsina1
 
PPTX
Zero Energy Buildings _ Rujan Timsina.pptx
RujanTimsina1
 
Solar Radiation by Rujan Timsina EEC.ppt
RujanTimsina1
 
Energy scenario and crisis in nepal by Rujan Timsina , part -1.pptx
RujanTimsina1
 
Energy scenario and crisis in nepal, Rujan Timsina.pptx
RujanTimsina1
 
Lecture 3 Biomass energy...............ppt
RujanTimsina1
 
world energy sources by rujan timsina.pptx
RujanTimsina1
 
RT bio mass or bio energy presentation .ppt
RujanTimsina1
 
Fuel cell by Rujan Timsina, ioe, tu .pptx
RujanTimsina1
 
energy scenario in the context of nepal.pptx
RujanTimsina1
 
Thermodynamics Lab manual for students.pptx
RujanTimsina1
 
Introduction to Energy Engineering Lab manual.pptx
RujanTimsina1
 
00 Introduction to theory of machine.pdf
RujanTimsina1
 
Fossil fuel RT rujan timsina .pptx
RujanTimsina1
 
Zero Energy Buildings _ Rujan Timsina-.pptx
RujanTimsina1
 
Zero Energy Buildings _ Rujan Timsina.pptx
RujanTimsina1
 
Ad

Recently uploaded (20)

PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PDF
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PPTX
ternal cell structure: leadership, steering
hodeeesite4
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PPTX
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
PPTX
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
ternal cell structure: leadership, steering
hodeeesite4
 
Inventory management chapter in automation and robotics.
atisht0104
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 

introduction to python in english presentation file

  • 2. Welcome Congratulations for deciding to participate in a 7 days of Introduction to Python Course. In this course you will learn the basics of programming using Python.
  • 3. Course Introduction This course is designed for beginners and intermediate who want to learn python programming language. In this course the topics are broken down into 7 days, where each day contains several topics with easy-to-understand explanations, real-world examples, many hands on exercises and a final project.
  • 4. Why Python? Python is a programming language which is very close to human language and because of that it is easy to learn and use. Python is used by various industries and companies (including Google). It has been used to develop web applications, desktop applications, system administration, and machine learning libraries.
  • 5. Installing Python  To run a python script you need to install python. Let's download python from https://www.python.org/.
  • 6. Installing VS Code  Visual Studio Code is a code editor (much like any other editor like Notepad) helpful in writing and editing codes.  We download it from here https://code.visualstudio.com/
  • 7. Basic Data-types  Boolean A boolean data type is either a True or False value. T and F should be always uppercase.  Integers (default for numbers) z = 5  Floats x = 3.1416  Complex Numbers x = 1+2j
  • 8. Basic Data-types  Strings • Can use “ ” or ‘ ’ to specify strings • a = “Nepal” • b = ‘Kantipur Engineering College’ • “abc” == ‘abc’ • Use “ ” if ’ already in string eg: “matt’s” • Use triple double-quotes for multi-line strings or strings than contain both ‘ and “ inside of them: “““a‘b“c”””
  • 9. Checking Data Types  To check the data type of certain data/variable we use the type function. >>> type(15) <class ‘int’> >>> type(3.14) <class ‘float’> >>> type(1+2j) <class ‘complex’> >>> str = “Hello World” >>> type(str) <class ‘string’>
  • 10. Naming Rules  Names are case sensitive and cannot start with a number.  They can contain letters, numbers, and underscores.  bob Bob _bob _2_bob_ bob_2 BoB  There are some reserved words: and, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, while  Can’t do this • for = 12 #for is a reserved word
  • 11. Assignment  Assign value to variables >>> x = 2  You can assign to multiple names at the same time >>> x, y = 2, 3 >>> x 2 >>> y 3  This makes it easy to swap values >>> x, y = y, x  Assignments can be chained >>> a = b = x = 2
  • 13. Mathematical Operators  Exercise: Find an Euclidian distance between (2, 3) and (10, 8)
  • 14. Mathematical Operators  Exercise: For a given temperature in celsius stored in variable ‘t_c’, get the Fahrenheit temperature in ‘t_f’ and display result. • Let t_c = 100 • ans = 212
  • 15. Checking Data Types  Exercise: What would be the data-type of? >>> a = 4/3 >>> type(a) >>> n = 4//3 >>> type(a) >>> num = ‘2080’ >>> type(num)
  • 16. Type Casting  Converting one data type to another data type.  We use int(), float(), str() >> # float to int >> gravity = 9.81 >> print(int(gravity))
  • 17. Type Casting  When we do arithmetic operations string numbers should be first converted to int or float otherwise it will return an error. >> #str to int or float >> num_str = '10.6‘ >> print('num_int', int(num_str)) >> print('num_float', float(num_str))
  • 19. Comparison Operators  In programming we compare values, we use comparison operators to compare two values. We check if a value is greater or less or equal to other value. >> 2 == 2 >> 3.14 == 3.1416 >> print(123 == ‘123’) >> print(123 == int(‘123’)) >> a = ‘mango’ >> b = ‘orange’ >> a == b >> a < b What does this show?
  • 21. Logical Operators  Logical operators are used to combine conditional statements: >> 2 == 2 and 2 < 4 True >> print() >> >> a = ‘mango’ >> b = ‘orange’ >> a == b >> a < b What does this show?
  • 22. Conditionals  In python the key word if is used to check if a condition is true and to execute the block code. Remember the indentation after the colon. a = 10 if a > 3: print(a, “is greater than 3”)  if else a = 3 if a > 0: print(a, “is positive number”) else: print(a, “is negative”)
  • 23. Conditionals  if elif else a = 3 if a > 0: print(a, “is positive number”) elif a < 0: print(a, “is negative number”) else: print(a, “is zero”)
  • 24. Operators and Conditionals  Exercise:  How do you check if a number is between 5 and 10 inclusive? Note: Use if statement here >>> if condition_1 and condition_2: ... choice_1 >>> else: ... choice_2 >>>
  • 25. Operators and Conditionals  Exercise:  How do you check if a number is even or not using python? Note: Use if statement here >>> if condition: ... choice_1 >>> else: ... choice_2 >>>
  • 26. Program for the Day Calculate Electricity Bill (15A) KWh Minimum Charge Charge per KWh 0 to 20 50 4.00 21 to 30 75 6.50 31 to 50 75 8.00 51 to 100 100 9.50 101 to 250 125 9.50 250 above 175 11 Ans: 2330 for 250 units
  • 27. Loops  In programming we also do lots of repetitive tasks. In order to handle repetitive task programming languages use loops. Python programming language also provides the following types of two loops: • while loop • for loop
  • 28. While Loop count = 0 while count < 5: print(count) count = count + 1 #prints from 0 to 4
  • 29. for Loop # syntax for iterator in range(start, end, step): #loop statements for i in range(1,10,1): print(i)
  • 30. for Loop num_list = [1,2,3,4,5] for num in num_list: print(num) it_companies = ['Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle', ‘Amazon‘] for company in it_companies: print(company)
  • 31. Program for the Day Student Grading SEE and NEB
  • 32. Program for the Day Student Grading SEE and NEB  For a given students’ mark in percentage, display letter grade for each student. marks = 90 Your code should display “Outstanding”
  • 33. Program for the Day Student Grading SEE and NEB  For a list of students’ marks in percentage, display letter grade for each student. marks = [95, 42, 78, 45, 89, 90] Use for loop