SlideShare a Scribd company logo
Python Programming
Quick summary
• A - In how many types, programming languages can be classified? And
what are the types?
• S - Comment on the scenarios where which type is the best?
• A- Explain the difference between the 2 types of programming
languages.
• S – Which types of language has faster execution and which has less
memory requirement.
• A – Which types of language is Python?
• S - Which of the following are valid variable names?
• Time1
• 3time1
• Time-1
• Time_1
• A - Which python inbuilt function is used to take input from user from
command prompt?
• S – What is a source code?
Running python from file
• 2 ways to run python source code from file:
• 1. Install an IDE e.g pycharm, spyder, thonny
• Check whether you have right version of python.
• Type in the python code
• Run the file by “Run” button.
• Alternatively, outside IDE
• Create a new “.py” file.
• Activate python virtual environment.
• Enter the source code in python file.
• GO on therminal
• Type the following command:
• python <filename.py>
Write the code for following program in
python file and run it.
• Write a program to take 3 sides of a triangle as input and output the
perimeter of a triangle.
• Hint(Perimeter of triangle is sum of all sides)
• Input –
• Enter 1st side of triangle
• Enter 2nd side of triangle
• Enter 3rd side of triangle
• Output
• Perimeter of triangle is <your answer>
Types of data in python
Setting the Data Type
• In python you don’t need to set data type explicitly. Python does it for
you when you declare the variable.
• The data type is set when you assign a value to a variable:
• x = “python class“ Data type = string
• x = 20.5 Data type = float.
• X = 4 Data type = integer
• X = True Data type = boolean
Checking the data type in python
• Get the data type of any variable by using the type() function.
• Example
• A = “I love python”
• type(A)
Convert from one data type to another
• Python has inbuilt functions to convert from one data type to another
• str(): converts any variable to string.
• int(): converts any valid integer from other data type to integer.
• float() : converts any valid integer form other data type to float.
• bool() : converts to boolean
Arithmetic operators
• %(mod) - remainder of
division
• ** - to the power
• // - integer division
Examples
• Open python shell
• Write code for 52
• Code for getting remainder from division of 625 and 19
• Write code for square root of 81
• Code for integer division 30 and 7
Get practical
• Easy - Write a program to convert kilometres to miles.
• Take kilometres as input
• Conversion factor = 0.621371
• Multiply kilometres by conversion factor.
• Hard –
• Python Program to Calculate the Area of a Triangle

More Related Content

PPTX
Python for Security Professionals
PDF
Python for All
PDF
An Introduction to Python Programming
PPTX
An introduction to java programming
PPTX
Python with data Sciences
PPT
Byte stream classes.49
PDF
Static vs dynamic types
PPTX
Introduction about Python by JanBask Training
Python for Security Professionals
Python for All
An Introduction to Python Programming
An introduction to java programming
Python with data Sciences
Byte stream classes.49
Static vs dynamic types
Introduction about Python by JanBask Training

What's hot (20)

PPT
Modern Compiler Design
PPTX
Introduction to Python Part-1
PPTX
Generics In and Out
PPTX
Java Tutorial Lab 6
DOCX
PYTHON NOTES
 
PDF
Javaiostream
ODP
Introduction to programming with python
PPTX
Python Tutorial Part 1
PPTX
Python ppt
PDF
TARGETED ADVERSARIAL EXAMPLES FOR BLACK BOX AUDIO SYSTEMS - Rohan Taori, Amog...
PDF
Python Data Types
PPTX
Python 3 Programming Language
PPT
20 intro-to-csharp
PDF
Aaa ped-3. Pythond: advanced concepts
PPTX
Java Tutorial Lab 4
PPTX
Fundamentals of Python Programming
PDF
Introduction To Programming with Python
PPT
Character stream classes .52
PPSX
JAVA VIRTUAL MACHINE
Modern Compiler Design
Introduction to Python Part-1
Generics In and Out
Java Tutorial Lab 6
PYTHON NOTES
 
Javaiostream
Introduction to programming with python
Python Tutorial Part 1
Python ppt
TARGETED ADVERSARIAL EXAMPLES FOR BLACK BOX AUDIO SYSTEMS - Rohan Taori, Amog...
Python Data Types
Python 3 Programming Language
20 intro-to-csharp
Aaa ped-3. Pythond: advanced concepts
Java Tutorial Lab 4
Fundamentals of Python Programming
Introduction To Programming with Python
Character stream classes .52
JAVA VIRTUAL MACHINE
Ad

Similar to Python programming l2 (20)

PDF
Introduction to Python - Jouda M Qamar.pdf
PPTX
Introduction to python for the abs .pptx
PPTX
python
PPTX
2. Values and Data types in Python.pptx
PPTX
Python Tutorial for Beginner
PPTX
Python basics
PPT
Python - Module 1.ppt
PDF
Sessisgytcfgggggggggggggggggggggggggggggggg
PPTX
Python Programming-1.pptx of python by computer
PPTX
introduction to python programming concepts
PDF
Intro-to-Python-Part-1-first-part-edition.pdf
PPTX
python_class.pptx
PPTX
Python basics
PPTX
IOT notes,................................
PPTX
Python variables and data types.pptx
PPTX
Introduction to python
PPTX
Python Basics
PDF
The python fundamental introduction part 1
PPTX
Lecture on Fundamentals of Python Programming-1
PPTX
Lecture1.pptx
Introduction to Python - Jouda M Qamar.pdf
Introduction to python for the abs .pptx
python
2. Values and Data types in Python.pptx
Python Tutorial for Beginner
Python basics
Python - Module 1.ppt
Sessisgytcfgggggggggggggggggggggggggggggggg
Python Programming-1.pptx of python by computer
introduction to python programming concepts
Intro-to-Python-Part-1-first-part-edition.pdf
python_class.pptx
Python basics
IOT notes,................................
Python variables and data types.pptx
Introduction to python
Python Basics
The python fundamental introduction part 1
Lecture on Fundamentals of Python Programming-1
Lecture1.pptx
Ad

Recently uploaded (20)

PDF
Empowerment Technology for Senior High School Guide
PDF
1_English_Language_Set_2.pdf probationary
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
IGGE1 Understanding the Self1234567891011
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
Computer Architecture Input Output Memory.pptx
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
20th Century Theater, Methods, History.pptx
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Empowerment Technology for Senior High School Guide
1_English_Language_Set_2.pdf probationary
Weekly quiz Compilation Jan -July 25.pdf
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
IGGE1 Understanding the Self1234567891011
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
What if we spent less time fighting change, and more time building what’s rig...
FORM 1 BIOLOGY MIND MAPS and their schemes
Unit 4 Computer Architecture Multicore Processor.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
AI-driven educational solutions for real-life interventions in the Philippine...
Computing-Curriculum for Schools in Ghana
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Computer Architecture Input Output Memory.pptx
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
20th Century Theater, Methods, History.pptx
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
TNA_Presentation-1-Final(SAVE)) (1).pptx
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين

Python programming l2

  • 2. Quick summary • A - In how many types, programming languages can be classified? And what are the types? • S - Comment on the scenarios where which type is the best? • A- Explain the difference between the 2 types of programming languages. • S – Which types of language has faster execution and which has less memory requirement. • A – Which types of language is Python?
  • 3. • S - Which of the following are valid variable names? • Time1 • 3time1 • Time-1 • Time_1 • A - Which python inbuilt function is used to take input from user from command prompt? • S – What is a source code?
  • 4. Running python from file • 2 ways to run python source code from file: • 1. Install an IDE e.g pycharm, spyder, thonny • Check whether you have right version of python. • Type in the python code • Run the file by “Run” button. • Alternatively, outside IDE • Create a new “.py” file. • Activate python virtual environment. • Enter the source code in python file. • GO on therminal • Type the following command: • python <filename.py>
  • 5. Write the code for following program in python file and run it. • Write a program to take 3 sides of a triangle as input and output the perimeter of a triangle. • Hint(Perimeter of triangle is sum of all sides) • Input – • Enter 1st side of triangle • Enter 2nd side of triangle • Enter 3rd side of triangle • Output • Perimeter of triangle is <your answer>
  • 6. Types of data in python
  • 7. Setting the Data Type • In python you don’t need to set data type explicitly. Python does it for you when you declare the variable. • The data type is set when you assign a value to a variable: • x = “python class“ Data type = string • x = 20.5 Data type = float. • X = 4 Data type = integer • X = True Data type = boolean
  • 8. Checking the data type in python • Get the data type of any variable by using the type() function. • Example • A = “I love python” • type(A)
  • 9. Convert from one data type to another • Python has inbuilt functions to convert from one data type to another • str(): converts any variable to string. • int(): converts any valid integer from other data type to integer. • float() : converts any valid integer form other data type to float. • bool() : converts to boolean
  • 10. Arithmetic operators • %(mod) - remainder of division • ** - to the power • // - integer division
  • 11. Examples • Open python shell • Write code for 52 • Code for getting remainder from division of 625 and 19 • Write code for square root of 81 • Code for integer division 30 and 7
  • 12. Get practical • Easy - Write a program to convert kilometres to miles. • Take kilometres as input • Conversion factor = 0.621371 • Multiply kilometres by conversion factor. • Hard – • Python Program to Calculate the Area of a Triangle