Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views28 pages

Python Programming

The document is a lecture series on Python programming for beginners, covering its features, installation, and basic syntax. It explains how to use Python, including comments, keywords, data types, variables, and user input. Additionally, it provides examples of printing messages, formatting data, and typecasting in Python.

Uploaded by

rabeenullah47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views28 pages

Python Programming

The document is a lecture series on Python programming for beginners, covering its features, installation, and basic syntax. It explains how to use Python, including comments, keywords, data types, variables, and user input. Additionally, it provides examples of printing messages, formatting data, and typecasting in Python.

Uploaded by

rabeenullah47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Lecture_01

09/01/2024
PYTHON
PROGRAMMING
FOR BEGINNERS
INTRODUCTION (WHAT IS PYTHON)

• It is an open source language


• Cross Platform: can run equally on different platforms such
as windows, Linux, Unix and Macintosh etc.
• Simple
• High level programming language
CONTINUOUS…

• Application done python. E.g. Google, YouTube, NASA, Drop


Box, AI, Image processing, Web Application, Game
Application etc.
• It is functional programming language and OOP.
• Python is scripting language
• All in one programming language
HOW TO USE PYTHON:

Requirements:
1: install Python
2: install a text editor for python like PyCharm.
Note: PyCharm is a special IDE for Python.
HOW TO DOWNLOAD AND INSTALL PYTHON?

• To install python:
Google
Type (Download Python)
Click on first link
Click on (download python 3.12.1) “almost 25 MBs”.
Once your download has been completed you can install it.
TO DOWNLOAD PYCHARM IDE:

Google
Type (download PyCharm)
Click on first link
Choose your OS (operating system)
Select Community for free downloading “almost 430 MBs”
Download and install it
TO PRINT A SIMPLE MESSAGE IN PYTHON:

Open python
Type: print (“hello world”)

Print (“”): is a function used to print a message for user


Between the brackets we can put any message.
Lecture_02
10/01/2024
COMMENT AND KEYWORDS IN PYTHON:

• Comments are used for two purposes:


1: to comment about your code
2: to check bugs in your code
• We have two types of comments in python:
1: single line comment 2: multiline
comment
CONTINUOUS…

#: is used for single line comments.


“””: three double quotes are used in the start of the multiline
comment and also three are used in the end of the multiline
comment.
Note: also we can use three single quotes (‘’’) to for both
starting and ending.
CONTINUOUS…

• Python allow you to write single line code.


1: eid,ename,esalary= 1,”abdulbasit”,3000.6
2: x,y,z=50,40,30
3: x=y=z=90
But: x,y,z=90 invalid
KEYWORDS:

• Keywords are predefine words or reserve words we can’t


use it as variable or function name.
• To print all keywords in python:
Import keywords
Print(keyword.kwlist)
DATA TYPES:
• In python generally we have only numbers,
str and Boolean data types.
1: int & float 100 & 100.5
2: str “abdulbasit” or ‘abdulbasit’
3: Boolean true or false
Lecture_03
11/01/2024
CONTINUOUS…

Python is dynamically typed language, you don’t need to


specify the type of variable:
1: id = 1 ename = “abdulbasit” esalary = 500.6
2: to check the type of a variable we need to use type(_variable)
function
Like: print(type(id))
So id is a variable we want to check it’s type
WHAT IS VARIABLE?

• Variable is a container used to store data like: in the above


example x, y, z, eid, ename, esalary.
• You can choose any name for your variable, but you can’t
use any keyword as a variable name.
• A variable can store different type of data like: integer,
string and Boolean.
PRINTING IN PYTHON:

• We use print(‘’) function to print data in python.


• Concatenation: in python it is possible to concatenate only
similar data types.
• Like: a= “abdulbasit” b=“Farooqi” print (a+b)
• Python allow you to reassign variable
• Like: salary = 900 print(salary) salary = 8000 print (salary)
CONTINUOUS…

• Swapping data in python


• Like: x=10 y=20 print(x) print (y) x,y = y,x print (x)
pirnt (y)
• Python allows you to delete a variable in order to release
space
• Like: num = 50 print (num) del num print(num)
• Printing data in python
USING VARIABLE INSIDE MESSAGE AND REASSIGNING VARIABLE:
USING: PRINT(“MY NAME IS “,A,”AND I AM A “,B,” TEACHER”)

Code: Output:
USER INPUT:
USING: INPUT(“MESSAGE”)

• To get data from user we use the function input(“message”)


function. This function used to take different format in old
version of python, but in the latest version of python it
takes data only in string format, it is out task to typecast
the data according to our need.
TO TAKE NAME FROM USER:
USING: INPUT(“MESSAGE”)
INTEGER TYPECASTING:
USING: INT(INPUT(“MESSAGE”))
FLOAT TYPECASTING
USING: FLOAT(INPUT(“MESSAGE”))
FORMATTING DATA:

• In project level we format data in two ways:


1: int float str
%d %g and %f $s
%g: is for two decimal points.
%f: is for six decimal points.
2: { }
EXAMPLE OF FORMATTING:
USING: %D, %G, %F, %S
USING:
PRINT(“NAME=%S NETSALARY=%F” %(NAME,NET_SALARY))

print("name = {}, net_salary = {}",format(name,net_salary))

You might also like