0% found this document useful (0 votes)
19 views

Lesson 4 Introduction To Python

Uploaded by

luayboyong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Lesson 4 Introduction To Python

Uploaded by

luayboyong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

INTRODUCTION TO PYTHON

3.5.2
What is Python?
Python is a general purpose, high level, interpreted
language with easy syntax and dynamic semantics
Created by Guido Van Rossum in 1989
Why is Python is Popular?
Easy - Python is language preferred by beginners
and pro like
Free – Python is an open-source language which
makes it free for everyone to use
Applications – Python can be used for desktop,
web, mobile application development
Library and Support – Python has great community
who constantly make libraries and help those in
need
Features of Python
Where is Python used in the Industry?

Better search results are provided based on


ranking of the websites and much more

The Server and Client applications are


coded using Python

Machine learning is used to cluster users


based on their interest on shows and retain
them for longer
Where is Python used in the Industry?
Cyber-security analysis and other
encryption and decryption work is done
using Python

Transfer of files between peer-to-peer which


started out as a normal Python file

Scientific calculations are computed using


Python
Career Opportunities
IDLE
simple integrated development environment (IDE)
allows to type program and run
First Program
Step 1: Start IDLE and open new window. Type:

Step 2: Press F5 or click Run and Save. Append .py to


the filename.

Input: ask the user to type something in


String: prompt that user sees
Eval: compute the expression entered by the user
Print: print the output
Reserved Words

All the Python


keywords contain
lowercase letters only
Second Program
Here is a program that computes the average of two
numbers that user enters:

Typing Things in:


Case – To python, print, Print, PRINT are all different things.
Most python statements are in lowercase
Spaces – Spaces matters at the beginning of lines
Indentation – To python, some statements ending with :
required indentation.
Getting Input
The input function is a simple way for your program to
get information from user.
The basic structure:
Here is an example:
Printing
The print function requires parentheses

To print several things at once, separate them by commas


Quotation in Python
Python accepts single (‘), double (“) and triple (“““)
quotes to denote string
Quote starts and ends the string
Triple quotes – span the string across multiple lines
Comments in Python
hash (#) – place at the beginning of a comment
Comment – set as mark and Python ignores these
Optional Arguments
sep – short for separator, change space to any symbol

end – advanced to the next line


Variables
Variable remembers the value of certain data
Variable Names
Variable names can contain letters, numbers, and the
underscore
Variable names cannot contain spaces
Variable names cannot start with a number
Case matters – temp and Temp are different
THE SECRET OF GETTING
AHEAD
IS GETTING STARTED
LABORATORY ACTIVITY NO.4
INTRODUCTION TO PYTHON
A. INTRODUCTION:
B. EXERCICES:
• Write a Python program which accepts the radius of a circle from the user and compute the area.
• Write a Python program to calculate body mass index.
• Write a Python program to convert seconds to day, hour, minutes and seconds.
• Write a Python program to display the current date and time.
• Write a Python program that will accept the base and height of a triangle and compute the area.
• Write a Python program to convert pressure in kilopascals to pounds per square inch, a millimeter of
mercury (mmHg) and atmosphere pressure.
• Write a Python program which accepts the user's first and last name and print them in reverse order.
• Write a Python program to print the calendar of a given month and year.
C. CONCLUSION:

You might also like