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

10th Class - Python

The most important part about the game in terms is how you play your game in your own style of play as a player in your own way as you develop your character as you go along the course to the game in the first round and you will have a better experience in your next turn and your character as a person in your turn will become the best in the first set of rules you will have the chance of learning from that game as you learn from the experience you are learning from your experience in this game a

Uploaded by

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

10th Class - Python

The most important part about the game in terms is how you play your game in your own style of play as a player in your own way as you develop your character as you go along the course to the game in the first round and you will have a better experience in your next turn and your character as a person in your turn will become the best in the first set of rules you will have the chance of learning from that game as you learn from the experience you are learning from your experience in this game a

Uploaded by

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

What is

python
Python is a computer programming language often
used to build websites and software, automate tasks,
and conduct data analysis. Python is a general-
purpose language, meaning it can be used to create
a variety of different programs and isn't specialized
for any specific problems
or
Python is a high-level, interpreted, general-purpose
programming language. Its design philosophy
emphasizes code readability with the use of
significant indentation. Python is dynamically-typed
and garbage
What is
Programming
Language
As we know, to communicate with a person, we need a
specific language, similarly to communicate with
computers, programmers also need a language is
called Programming language. Before learning the
programming language, let's understand what is
language
What is Language

Language is a mode of communication that is used


to share ideas, opinions with each other. For example,
if we want to teach someone, we need a language that
is understandable by both communicators
What is Programming Language

A programming language is a computer language that


is used by programmers
(developers) to communicate with computers.
It is a set of instructions written in any specific
language ( C, C++, Java, Python) to perform a specific
task
Usage of Programming
Language
A programming language is mainly used to develop
desktop applications, websites, and
mobile applications and other
softwares.
Hardware Software Firmware

Programming
System Software Application software Language
Software
Programming
language software

Low Level P-L High Level P-L


Low Level Programming Langage

Low-level language is machine-dependent


(0 and 1) programming language. The
processor runs low- level programs
directly without the need of a compiler or
interpreter, so the programs written in
low-level language can be run very fast.
But understanding low level language for
user are very difficult
High Level Programming Language
High-level programming language (HLL) is designed for developing user-friendly
software programs and websites. This programming language requires a compiler or
interpreter to translate the program into machine language (execute the program).
The main advantage of a high-level language is that it is easy to read, write, and
maintain.
High-level programming language includes Python, Java, JavaScript, PHP, C#, C++,
Objective C, programming language.
What is program
Programs are collection of
instructions executed by
computer or user to perform
specific tasks on computer
Or
Program is a collection of data
and a set of
Instruction or procedure on that
data to do a
Specific task.
How we can make a software
For making a program we must know
the programming language programs
like c, c++ , c# , java

If we know these programs we can make


a program or a application
The basic program in making software
and program or websites in python
What is Python
Python is a computer programming
language often used to build websites
and software, automate tasks, and
conduct data analysis. Python is a
general-purpose language, meaning it
can be used to create a variety of
different programs and isn't
specialized for any specific problems
or
Python is a high-level, interpreted,
general-purpose programming
language. Its design philosophy
emphasizes code readability with the
use of significant indentation. Python
is dynamically-typed and garbage
Usage of Python
• Using of Artificial intelligence in python
• In dynamic web designing
• In making robots
• For testing software and webpages
• For Cyber security
• For making simple Script
• For making program
• For linking database to web sites
• For making Mobile Application
Python Certification Level
• PCEP- python certified Entry professional
• PCAP-python certified Associate professional
• PCPP-python certified professional programming
• CEPP-Certified expert in python programming
What is Editor , Compiler, Debuger
Editors and IDE
are the programs which we
can write the codes on it
Compiler List
Compiler ▪ Programiz.
compiler is a special ▪ PyDev.
program that Convert our
written statement in a ▪ PyCharm.
programming language ▪ Sublime Text.
into machine language or
“Binary". Typically, a ▪ Thonny.
programmer writes ▪ Visual Studio Code.
language statements in a
language such as Pascal or ▪ Jupyter Notebook.
C one line at a time using ▪ Vim
an editor
What is Data Type
A data type, in programming, is a classification that
specifies which type of value a variable has and what type
of mathematical, relational or logical operations can be
applied to it without causing an error , and these are the
data types

X=1 Number(int)
y=1.2 Float
Z=1j Complex
P=‘ahmad’ String

Print(x) it show the data type of a variable

Print(type(x))
Print(type(y))
Print(type(z))
What is Variable

A variable is a way of storing information in a computer


program. Think of a variable like a container and the name
of the variable as the label on the container which shows us
what is inside
❖ The first character
of a variable
X=1 must not start with number
y=1.2
Z=1j
❖ No Space in variable
P=‘ahmad’
❖ Variable can accept and under
score
Print(type(x)) ❖ We can not write the command
Print(type(y)) of python as a name of veriable
Print(type(z))
keyboard=4000
Computer=3000
Print(keyboard+Computer)
keyboard=‘4000’
Computer=‘3000’
Print(keyboard+Computer) it gives Error

keyboard=‘4000’
Computer=‘3000’
Print(int(keyboard)+int(Computer))
String
Properties
• We must write string on quotation we can write the
string in single quotation and also in double quotation
• X=“welcome to python”
• X=‘welcome to pyton’
• Print (x)
• Print(x.title())
• Print(x.upper())
• Print(x.lower())
String Properties
• First_Name=‘Ahmad Kareem’
• Last_Name=‘Popalzai’
• Full _Name=First_Name+’ ‘ +Last_Name
• Print(Full_Name)

print('ahmad kareem')
print('\tahmad naim')
print('languages:\npython\nc++\njavascript\n')
print('languages:\n\tpython\n\tc++\n\tjava script\n’)
name=‘ahmad ‘
Print(name.rstrip())
Print(name.Lstrip())
Print(name.strip())
Number Properties
• In python we us int and float for numbers
• We can add operation on all numbers
• Int
• X=“289”
• Float • Print(Type(x))
• 10/30
• X=int(x)
• Print(type(x))
• Print(x)

• X=-7.5
• Print(abs(x))
Number Properties
Operator priority
• ()
• **
• */ the operator which is on the left
• +
• -

2*4-5/5 2**2*(19-14) X=456


8-5/5 2**2*5 x=x+90
8-1 4*5
7 20
Error type
Syntax Error

Runtime error
Syntax Error
Syntax error is a grammerical error in python
print 123
print(123)

Runtime Error
A runtime error in a program is an error that occurs while
the program is running after being successfully compiled
open(‘flower.jpg’)
Input from keyboard or user
name=input(“Enter your name:”)
X=int(input(Enter first Number:”))
Print(“your name is:”)
y=int(input(Enter second Number:”))
Print(name)
Total=x+y
---------------------------------------------
Print(total)
name=input(“Enter your name:”)
Print(f“your name is {name}”)

X=float(input(Enter first Number:”))


y=float(input(Enter second Number:”))
Total=x+y
Print(total)
What is Library
A Python library is a collection of related modules. It
contains bundles of code that can be used repeatedly in
different programs. It makes Python Programming
simpler and convenient for the programmer.
Or
ython libraries are used to create applications and
models in a variety of fields, for instance, machine
learning, data science, data visualization, image and
data
What is Library
EX:

NumPy Library Advanced Math Functionality


Scipy Library For Scientific Functionalities
Tkinter Library For Graphical Design
Malplotlib For chas , plots , Graphs
from tkinter import *
Creating label
and Text BOX
window=Tk()
window.title("hi and Hello")
window.geometry('500x300')

lable1=Label(window,text='Enter Your Name:',fg='blue',font=('Arial',14))

lable1.grid(row=0,column=0,padx=5,pady=10)

textbox1=Entry(window,fg='blue',font=('Arial',14))
textbox1.grid(row=0,column=1)

window.mainloop()
import tkinter as tk
from tkinter.ttk import *

root = tk.Tk()
Creating
root.geometry('100x100')
Buttons
btn = Button(root, text='Click me!', command=root.destroy)
btn.pack(side='top')

root.mainloop()
from tkinter import * Creating
Scroll Bar
master = Tk()
w = Scale(master, from_=0, to=42)

in Python
w.pack()
w = Scale(master, from_=0, to=200, orient=HORIZONTAL)
w.pack()
mainloop()
The Python turtle library is a built-in module
that provides a fun and interactive way to learn What is
Turtle
programming concepts. It’s based on the Logo
programming language and allows users to
create pictures and shapes on a screen using a
metaphorical “turtle” Here are some key points
about the Python turtle library:
Library
1.Virtual Canvas: The turtle library gives you
a virtual canvas where you can draw and
create various types of shapes and images.
2.The Turtle: The onscreen pen that you use for
drawing is called the turtle. You can move this
turtle around the canvas, and it leaves a trail as
it moves.
A conditional statement in Python is a

Condition
programming construct
that allows you to make decisions
and execute different blocks
of code based on certain conditions.
in python
It allows you to control the flow
of your program based on whether a
condition is true or false
Conditional Statements are followings

1- IF Condition
2- IF and elf
3- IF AND
in python
4- IF OR
5- IF Not
Comparison Operator
Comparison operator can Compares numbers and
perform evaluations. And the result of comparision
operator can be true or false.
> X=2
< Z=3
>=
Print(x>y)
<=
Print(x<=y)
!=
Print(x==y)
==
Condition in python
X=float(input(“please Enter a number”))
if x>0:
print(“the Num is positive”)
else:
number=float(input(“please Enter a number”))
print(“the num is Negative”)
if number%2==0:
print(“the Num is even”)
else:
print(“the num is odd”)
today = 'Saturday' if today=='Sunday' or today=='Saturday': print('Today is off. Rest at home.')

today = input(str(“please Enter Name Of Days:”)


if today=='Sunday' or today=='Saturday’:
print('Today is off. Rest at home.’)
else: print('Go to work.') Name=str(input(Please Enter Name”))
Job=str(input(please Enter Job”))
salary=int(input(please Enter salary))
If job==‘doctor’ or job==‘eng’:
print(salary+5000)
Else:
Print(salary)
Print(“you are not doctor or eng”)
Condition in python
X=float(input(“Enter first number”))
Y=float(input(“Enter Second number”))

If x != y:
print(‘x is not equal to y’)
Else
print(“x and y variable values are equal”)
Name=str(input(Please Enter Name”))
Job=str(input(please Enter Job”))
salary=int(input(please Enter salary))
If job != ‘doctor’:
print(salary+5000)
Else:
Print(salary)
Print(“you are doctor”)
Python supports the usual logical conditions from
mathematics:
Equals: a == b Condition
Not Equals: a != b
Less than: a < b
in python
Less than or equal to: a <= b
Greater than: a > b
Greater than or equal to: a >= b
These conditions can be used in several ways, most
commonly in "if statements" and loops.
An "if statement" is written by using the if keyword.
In Python, loops are
essential for executing a Loops in
block of code repeatedly python
until a specific condition is
met. Let’s explore the two
main types of loops in
Python:
Python has two primitive loop commands:
1. while loops
2. for loops Loops in
Python
1- while loop
A while loop executes a block of statements
repeatedly as long as a given condition remains true
i=1

Loops in
while i < 6:
print(i)
i += 1 Python
count = 0
while count < 3:
print("Hello ")
count += 1
The break Statement
With the break statement we can stop the loop even if
the while condition is true: Loops in
i=1
while i < 6:
Python
print(i)
if i == 3:
break
i += 1
-----------------------------
i=1
while i <= 100: Loops in
print(i)
if i == 7:
Python
break
i += 1
Arrays are a fundamental data structure, and an
important part of most programming languages. In
Python, they are containers which are able to store
Array in
more than one item at the same time. Specifically, Python
they are an ordered collection of elements with every
value being of the same data type
There are two types of array in python
1- One Dimensional Array
2- Two Dimensional Array
Types of
Array
1- One Dimensional Array
This types of array has one row and multiple column

2- Two Dimensional Array


This type of array has multiple row and multiple
column – by default python can not support 2 dim
array
Stu_Roll_num1=2343
Stu_Roll_num2=2344
Stu_Roll_num3=2345 Example of
Array
Stu_Roll_num4=2346
Stu_Roll_num5=2347
-----------------------------------------------------------------
Print (Stu_Roll_num1)
Print (Stu_Roll_num2)
Print (Stu_Roll_num3)
Print (Stu_Roll_num4)
Print (Stu_Roll_num5)
Type
codes of
i

f
int

float
array in
python
From array import *
Array name = array (‘type code’,[ elements])
Array
Example Syntax
From array import *
Stu_roll_num=array(‘ i ‘ ,[2345,2346,2347,2348,2349])
Print(stu_roll_num[0])
For Loops
With the for loop we can execute a set of
statements, once for each item in a list,
tuple, set etc.
for x in "banana":
print(x)
For Loops
------------------------------------------------------------ and Array
Examples
s = "Geeks"
for i in s:
print(i)
for number in range(5):
print("Thank you")
For Loops
------------------------------------------------------------ and Array
Examples
for i in range(1,n):
print(i)
for i in range(0, 10, 2):
print(i)
For Loops
------------------------------------------------------------ and Array
Examples
given_range = 10
for i in range(given_range):
if i%2==0:
print(i)
fruits = ["apple", "banana", "cherry"]
for x in fruits:
For Loops
print(x) and Array
------------------------------------------------------------ Examples
list = [1,2,4,6,88,125]
for i in list:
print(i)

You might also like