You are on page 1of 77

RN Reddy IT School – Core Python

Core Python
by

Mr.R.N Reddy

RN Reddy IT School
Online/Classroom Training’s
For more details
Phone: +91 9577146777, 9885199122
E-Mail: Rnreddyitschool@gmail.com
Visit: www.rnreddyitschool.co
FB Page: - www.facebook.com/Reddyitschool
RN Reddy IT School – Core Python

Q) What is a python?

A) Python is a programming language.

Q) What are the prerequisites required to learn python?

A) Nothing

Q) Who has introduced python?

A) GUIDO VAN ROSSUM in 1989 he is from Netherland

Q) Why python is so popular in IT industry?

A) Because python is implementing in multiple areas like below

1. Data science
2. Data analytics
3. Machine learning
4. Deep learning
5. Artificial intelligence
6. Robotics
7. Big data mobile application
8. Data web application devotes
9. Testing
10. IOT ( internet of things)

Features of python
 Python is a very easy programming language
Example :- In c # or java if you want to write single line code we should write within
the main method on the main method should be within the same class like below
Public class program
{
Static void main (string []args)
{
//code
}
}
But in python we don't require to write main method
 Python code:-
Print(“hello”)
o/p :- hello
RN Reddy IT School – Core Python

Example:-

To declare a variable in c# or Java we need to mention the data type on statement


should end with semicolon (;) like below

C# or java code :

Int a=10;

but in python we don't require to mention the data type and semi colon like below

a=10

print(a)

o/p = 10

Example 3 :-
In C# for Java will have multiple numerical data types as well as multiple floating point data types but in
python we have only numerical data type
i.e int 0 and only one floating data type i.e (float)
python code :-
a=10
print(type(a))
o/p = int
a=10.4
print(type(a))
o/p = float

2) Python is a case sensitive language


Example:-
a=10
print(a)
o/p= error

3) Python is general purpose programming language


RN Reddy IT School – Core Python

Programming language of two types:

 Special purpose programming language


Example:-
SQL structured query language it is used for database
 General purpose programming language
Example:-
Java python c # it is used for develop the application
4) Python is cross platform programming language python application will be running on all
operating system
5) Python is open structure programming language
 Free software we can download from a website www.python.org
6)python is a procedure oriented programming language as well as object oriented
language python application is a collection of functions without having any classes due to
that reason it is called as procedural oriented programming language python application
can be developed by using classes and object with this we can say python is a object
oriented programming
7) Python is a modular programming language
Python library is a collection of packages, package is a collection of modules ,module is a
collection of functions and classes

Example:-

Functions
module 1
Classes
package 2 module 2
python
pakage
package 1 module 3

8) python is a dynamic type programming language programmer does not need to declare
any data type the data type will be taken automatically based on initialised value if we
initialise numerical value dynamically take as int
9) Python is interpreter based programming language
Python languages are two types
• Compiler based programming language
• Interpreter based programming language
RN Reddy IT School – Core Python

Compiler based programming language Interpreter based programming language

•In compiler in compiler best programming language •Example python in case of interpreter
program will get first compile once compilation is based programming language interpreter
completed entire program then only it will get execution engine will compile and
execute means here it will divide into two steps execute the code line by line like below
•Compilation doing compiler •Python interpreter program
•Execution is doing execution engine •line 1 ------->compile and execute
•Example for compiler based programming language •line 2 ------->compile and execute
c, c + +, Java, c# •line 3 ------->compile and execute
•In this process when we compile program it will •Observation in this casecode is compiling
produce collection of files which consume lot of and execution line by line due to that
memory for example if we compile c program it will reason it is not producing any supporting
produce following files files which will not consume more
•Object it will contain machine understandable code memory
•.exe it will contain executable code
•.bak(it will contain original program code as back up
•after compilation is compiled we will run .exe file for
execution

10) Python is embedded programming language

 We can integrate python code into Java code as well as .net code
 To integrate python code into Java code we have JYTHON http:// www.jython.org
Note:-

If you want to integrate python code into Java code we have to install Jython software , on
that software we should open Java application and we can write python code ,which will
convert as Java code by jython after this we can run this application on Java framework
RN Reddy IT School – Core Python

Programming environment of python


How to open python IDLE or program window?

start program python 3.8.0 click on IDLE

With this process it will open python program window write the below code

Print(“hello”)

o/p :- hello

Write below two lines of code

Print(“hi”)
o/p :- hi
Print(“hello”)
o/p :- hello

Observation

In the above program it will giving line by line output which is used for only testing not be
useful for development due to that reason python will support two programming modes

 Interactive mode
 Batch mode

Interactive mode
 how to open interactive mode

start program python 3.8.0 IDLE

It will open python code window


 Here we can write code like below
Print(“hi”)

o/p :- hi
RN Reddy IT School – Core Python

Note: - This interactive mode is used for only testing


Batch mode
 How to open batch mode
Note:-
This mode is used for development in this mode we will create an python
program file we will write one program in that file

start program python 3.8.0

 IDLE
 It will open
 Here go to menu
 Integrate python code into . Net code we have IRON pythonhttp://ironpython.net
NOTE:-

For this process first we have to install ironpython software and we have to open. Net
applications and we can write python code which will convert as .NET code by ironpython
finally we can run that application on.Net framework

How to open python IDLE integration development environment

start All program python 3.8.0 IDLE

 It will open python code window we can write our program like below
>>>print(‘welcome to python’)

O/P = welcome to python

File file name

 It will open a new file save as filename


 My program .py and select location on desktop
 Click save button with this process and window will open write the below code

Print(“hi”)
Print(“hello”)
RN Reddy IT School – Core Python

 Again save go to menu run module

Observation: - Here in this mode we are getting output in one shot

Program by using python language batch mode


 Write a python program to print 3 welcome message

Start all programs


 Expand python 3.8 folder on IDLE
 With this process it will open python program environment IDLE
CREATING PYTHON FILE :-

File new file it will open new file write the code below

Print(‘welcome to python’)

Print(‘welcome to programming’)

Print(‘welcome to sathya technology’)

O/P = welcome to python

welcome to programming

welcome to sathya technology

Save as select location as desktop file name as

first program.py Click on save

Go to menu run module or press F5


RN Reddy IT School – Core Python

Write a python program to print one numerical value one floating value and one string value

Example for numerical value : 10 (correct method)

-10 (correct method)

10.5 (wrong method)

Example for floating value : 10.5 (correct method)

-10.5 (correct method)

10 (wrong method)

10’ (wrong method)

Example for string value : ‘rama’ (correct method)

‘rama11’ (correct method)

’10.5’ (correct method)

‘ ’ (correct method)

Programming by using variable:-

Q) What is a variable?

A) A field which represent some value which can be changed is called as variable

Syntax to declare a variable :-

<variable name > = <value>

Example :-
A= 10
10
B = 20.5 20.5
C= ’rama’
rama
RN Reddy IT School – Core Python

Q) Write a python program to store a person ‘rama’ name into one variable called name and person
age 20 into another variable called age print these two values with the help of variables

Step 1 : design with output


output

Name rama

Step 2 : program Age 20

name='rama'
age=20
print(name)
print(age)
output :-

rama

20

Step 3 : Tracing
RN Reddy IT School – Core Python

Write a python program to store employee information i.e empno=111 empname=rama empsal=1000
into 3 variables they are empno ,empname and empsal print these three values with the help of
variables

Step 1 : design with output

output

empno 11

Step 2 : program empname rama

empno=111 empsal 1000


empname='rama'
empsal=1000
print(empno)
print(empname)
print(empsal)
output :-

111

rama

1000

Step 3 : Tracing
RN Reddy IT School – Core Python

Q) Write a python program to store student information sid= 123 sname=rama sloc= Hyd into three
variables sid,sname,sloc print these three values with the help of 3 variables

Step 1 : design with output

output

sid 123

Step 2 : program sname rama

sid=123 sloc hyd


sname=rama
sloc=hyd
print(sid)
print(sname)
print(sloc)

output :-

123

rama

hyd
RN Reddy IT School – Core Python

Step 3 : Tracing
RN Reddy IT School – Core Python

Q) Write a python program to store 3 subject marks 60, 70, 80 into three variables they are M1 M2 M3
calculate total marks Store into one variable called totmarks display the total marks with the help of a
message and variable

Step 1 : design with output

output

m1+m2+m3
total marks are: 210
Step 2 : program

m1=60
m2=70
m3=80
totmarks = m1+m2+m3
print('total marks are : ',totmarks)
output :-

total marks are : 210

Step 3 : Tracing:-
RN Reddy IT School – Core Python

Q) Write a python program three subject marks 60 70 80 into three variables M1 M2 M3 calculate total
marks store into one variable cal total marks and calculate average marks and store into another variable
called average marks print total marks and average marks with the help of messages and variables

Step 1 : design with output

output

m1+m2+m3
total marks = m1+m2+m3 total marks are : 210
Step 2 : program
=60+70+80 avg marks : 70
m1=60
m2=70 =210
m3=80 Avg marks= (m1+m2+m3)/3
totmarks = m1+m2+m3
avgmarks=(m1+m2+m3)/3 = 70
print('total marks are : ',totmarks)
print('avg marks are : ',avgmarks)

output :-

total marks are : 210

avg marks are : 70.0

Step 3 : Tracing
RN Reddy IT School – Core Python

Q) write a python program to store two product 1000,2000 into two variables they are P1 P2 calculate
total bill store into one variable called total bill and calculate 10% discount on total bill and store
discount in disc variable display the total bill after discount by using messages and variable

Step 1 : design with output


output

p1=1000 totbill = 2700

p2=2000
Step 2 : program
totbill = p1+p2
p1=1000 =100+2000
p2=2000
totbill = p1+p2 =3000
disc=totbill*0.10 Disc = totbill*0.10
totalbill = totbill - disc
print('total bill is : ',totalbill) =300

Totbill = totbill-disc
output :-
=3000-300
total bill is : 2700.0
=2700

Step 3 : Tracing
RN Reddy IT School – Core Python

Q) Write a python program to store two product cost 1000,2000 into two variables they are P1 P2 and
calculate total bill store into to one variable called total bill on total bill calculate 20% discount and store
into one variable called disc after discount calculate 30% tax on total bill and display total bill with the
help of messages and varible
output
Step 1 : design with output
p1=1000 totbill is = 3120

p2=2000

totbill = p1+p2

Step 2 : program =100+2000

p1=1000 =3000
p2=2000
Disc = totbill*0.20
totbill = p1+p2
disc=totbill*0.20 =600
totabill = totbill - disc
tax=totabill*0.30 Totbill = totbill-disc
totalbill=totabill+tax =3000-600
print('total bill is : ',totalbill)
=2400

output :- Tax = totbill*0.30

total bill is : 3120.0 =2400*0.30

=720

Totbill= totbill+tax

=2400+720

=3120
RN Reddy IT School – Core Python

Step 3 : Tracing
RN Reddy IT School – Core Python

Q) Write a python program to store 3 product costs 2000,3000, 4000 into three variables there P1 P2 P3
calculate total bil store into one variable called total bill on total bill 30% discount and 40% tax finally
display the total bill after discount and tax with the messages on wearable implement this by using four
steps

i. Design with output


ii. Program
iii. Tracing
iv. Program in lappy output
Step 1 : design with output
p1=2000 totbill is = 8820

p2=3000

p3=4000

Step 2 : program totbill = p1+p2+p3

p1=2000 =2000+3000+4000
p2=3000
=9000
p3=4000
totbill = p1+p2+p3 Disc = totbill*0.30
disc=totbill*0.30
totabill = totbill - disc =2700
print('after discount total bill is : ',totabill) Totbill = totbill-disc
tax=totabill*0.40
totalbill=totabill+tax =9000-2700
print('total bill is : ',totalbill)
=6300
output :-
Tax = totbill*0.40
after discount total bill is : 6300.0
=2520
total bill is : 8820.0
Totbill= totbill+tax

=6300+2520

=8820
RN Reddy IT School – Core Python

Step 3 : Tracing
RN Reddy IT School – Core Python

P1 = 1000 on P1 10% discount

P2 =2000 on P2 20% discount

Calculate total bill on total bill 30% discount after discount on total bill 40% tax finally display total bill
after tax

Step 1 : design with output

Step 2 : program

p1=1000
p2=2000
p1disc=p1*0.10
p2disc=p2*0.20
p1=p1-p1disc
p2=p2-p2disc
totbill=p1+p2
disc=totbill*0.30
totbill=totbill-disc
tax=totbill*0.40
totalbill=totbill+tax
print('total bill is :',totalbill)
OUTPUT :-

total bill is : 2450.0

Write a python program to store to product cost 1000 ,2000 into two variables they are P1 and P2 on P1
10% discount and 20% tax on p to 20% discount on 30% tax calculate total bill and store into one variable
called total bill finally print total bill with messages and variable

Step 1 : design with output

Step 2 : program

p1=1000
p2=2000
p1disc=p1*0.10
p1=p1-p1disc
p1tax=p1*0.20
p1=p1+p1tax
p2disc=p2*0.20
p2tax=p2*0.30
p2=p2+p2tax
totbill=p1+p2
print('total bill is :',totbill)

output :-
RN Reddy IT School – Core Python

total bill is : 3680.0

Step 3 : Tracing

Building functions in python:-


In python we have built in functions:

 Print ()
This method will print the given value
 Type()
This method will return type of the given variable or value

 ID()
This method will return variable address

For example :-
A=10 1234567890
Id=(a)
RN Reddy IT School – Core Python

Data types in python:-


 In python data types specifies the type of the data in python data types classified
into three types
i. Fundamental data types
ii. collection data types
iii. other data types

Fundamental data types


Fundamental data types are primary data types these data types are the main data types
in python

They are:-

 Int
 Float
 str
 bool
 complex
int :

In python we have only one numerical data types this data type represent a numerical
value which doesnot have any fractional point

Example for int : 10 , 20 ,30

Real time example for int : age=20

Eno=524

Sid=58986

Float

A number which having a fractional value either can be +ve or –ve

Example :- 10.5, 20.6

Real time example for float :- temp=35.2

Height=63.5
RN Reddy IT School – Core Python

Str:-

Collection of charcter which is enclosed with single quote , double quote , triple quote

Example for string :- a=”rama”

B=’sita’

Bool:-

Bool represent either true value ore false valuetrue will be storing as binary 1 and false
will storing as binary 0

Example : a= true ---------1

B=false---------0

Complex:-

This data type will not use in business application in we will use in scientific application

For example: a=(10+5j)

Type(a) 10+5j

Output :- <class ‘complex’>


RN Reddy IT School – Core Python

Typecasting for fundamental data types


Q) What is type casting?

A) converting from one data type to another data type is called type casting

Python support following type casting methods

 int ()
 float ()
 string ()
 bool()
 complex()
int ()
 int(‘rama’)
This method will convert the given value into int type a=10.5
o/p = error

 int(true)  int(‘10+5j’)
Example :-
a=10.5 o/p = 1 o/p = error

int(a)  int(false)
 int(20.3)
output = 10 o/p = 0
o/p = 20

Observation

Int() function will come not for all the types except complex type

Float

this method will convert the given any type value into float accept complex

 float(true)
Example :- o/p = 1.0

 float(false)  float(‘10+5j’)
 float(20) o/p = error
o/p = 0.0
o/p = 20.0
RN Reddy IT School – Core Python

Str():-

Using this function we can convert into string type


 str (true)  str (320)
Example :-
o/p = true o/p = 320

 str(20.3)  str(false)  str (10+5j)

o/p = 20.3 o/p = false o/p = 10+5j

Observation:-

String function can convert from complex to string type

Bool()

This function will convert given volume to bool type


 bool(10)  bool (10.5j)
o/p = true o/p = true

 bool(rama)

o/p = true

complex ()

This function will convert given volume to complex type

Example:-  Complex(‘rama’)

o/p = error (string cannot be


 complex(10)  complex(10.5) converted into complex)
o/p =10+0j o/p =10.5+0j
RN Reddy IT School – Core Python

Q) How to accept input from user


A) By using input function

About input function:-


Input function will accept input from the user by displaying user-friendly message once
user centre it will return the accepted value as string value

Programming by using input function :-


Write a python program to accept name from user and display to the user

Step 1:- Design with output output

Name enter u r name: rama

Rama your name is rama


STEP 2 :- Program

name=input('enter your name :')


print('your name is',name )

o/p = enter your name :rama

your name is rama


step 3 :- TRACING
RN Reddy IT School – Core Python

Q) write a python program to accept two numbers from the user and store into a and b perform addition
display addtion result

step 1 :- Design with output Output

step 2 :- Program A=10 enter first number:10

a=input('enter first number : ') B=20 enter second number:20


b=input('enter second number : ')
Addition result : 30
result=int(a)+int(b)
print('addition result:' ,result)

output:-
enter first number : 10
enter second number : 20
addition result: 30
step 3 :- Tracing

Q) write a python program to accept three subject marks M1 M2 M3 calculate the total marks and
average marks find the total marks and average marks
Output
step 1 :- Design with output
M1=60 enter m1 marks : 60

M2=70 enter m2 marks : 70

M3=80 enter m3 marks : 80

Total marks total marks = 210/3


step 2 :- Program
(m1+m2+m3)/3 =70
m1=float(input('enter m1 marks : '))
m2=float(input('enter m2 marks : '))
m3=float(input('enter m3 marks : '))
totalmarks=m1+m2+m3
averagemarks=(m1+m2+m3)/3
print('total marks are:' ,totalmarks)
print('average marks are:' ,averagemarks)
RN Reddy IT School – Core Python
output :-

enter m1 marks : 60
enter m2 marks : 70
enter m3 marks : 80
total marks are: 210.0
average marks are: 70.0

Q) write a python program to accept two products cost b1 b2 calculate total bill on totalbill calculate 10%
discount display the total bill after discount
output
step 1 :- Design with output
P1=1000.0(using float) enter p1=1000

P2=2000.0(using float) enter p2=2000

Totbill =p1+p2 totalbill=2700


step 2 :- Program
= 3000
p1=float(input('enter p1 : '))
p2=float(input('enter p2 : ')) Disc = totbill*0.10
totbill=p1+p2
disc=totbill*0.10 = 300
totalbill=totbill-disc Totalbill=totbill-disc
print('total bill is:' ,totalbill)

output:-

enter p1 : 1000
enter p2 : 2000
total bill is: 2700.0

step 3 :- Tracing
RN Reddy IT School – Core Python

Q) write a python program to accept two product cost P1 P2 and P1 10% discount and P2 20% discount
calculate total bill on total bill 30% tax display after discount and display tax finally display the total bill
after tax

step 1 :- Design with output output

P1disc=p1*0.10 enter p1 cost=200

step 2 :- Program P1=p1-p1disc enter p2 cost=400

p1=float(input('enter p1 cost : ')) P2disc=p2*0.20 p1 price=180


p2=float(input('enter p2 cost : '))
P2=p2-p2disc p2 price=320
discp1=p1*0.10
p1=p1-discp1 Totbill =p1+p2 total bill after tax=650
discp2=p2*0.20
p2=p2-discp2
totbill=p1+p2 Tax= totbill*0.30
disc=totbill*0.30
Totalbill=totbill+tax
totalbill=totbill+disc
print('total bill is:' ,totalbill)
output:-

enter p1 cost : 200

enter p2 cost : 400

total bill is: 650.0

step 3 :- Tracing
RN Reddy IT School – Core Python

Q) write a python program to accept two numbers and perform division and display the division result

step 1:-

program

a=int(input('enter first number:'))


b=int(input('enter second number:'))
c=a/b
print(c)

output:-

enter first number:10

enter second number:2

5.0

 For the above program if you have entered first numbers 10 second number zero is
throughing divide by zero error
Q) How to handle runtime error?

A) To handle runtime error with the help of logic we should go to the control statement
RN Reddy IT School – Core Python

Control statement
What we can do by using control statement using control statement we can control the
program according to our requirement

When we will go for a control statement?

Whenever you want to go to control the program according to all in one requirement go
for control statement

In python there are three types of control statements

 Conditional statement
 Loops
 Transfer statement

Conditional statement
Q) What we can do by using conditional statement?

A) Using conditional statement we can execute single statement or multiple statements


based on condition

Q) When will go for conditional statement ?

A) Whenever we want to execute a single statement on multiple statement based on


condition will go for conditional statements

Types of conditional statement

in python we have these following conditional statements

 simple if
 if else
 if elif if
 multiple if
 nested if

simple if:-

<syntax>

If <condition>:
RN Reddy IT School – Core Python

Q) Example to handle the divide by zero error by using simple if

step 1 :-Design with output Output


Program A=10 enter first number:10
a=int(input('enter first number:')) B=5 enter second number : 0
b=int(input('enter second number:'))
if b==0: Please enter the second number
b=int(input('plese enter second number
other than zero:' ,)) Other than zero:5
c=a/b Division result is :2
print('division result is : ', c)

output:-

enter first number:10

enter second number:0

plese enter second number other than zero:5

division result is : 2.0

if else:-

<syntax>
If <condition>:
Statement1
Else
Statement2
Q) Write a python program to compare i and j

Step 1:- design with output:


Output

I=10 enter i value: 10


Step 2:- program
J=5 enter j value:5
i=int(input('enter i value:'))
j=int(input('enter j value:')) I is greaterthan j
if i>j:
print('i is greaterthan j')
else:
print('j is greaterthan i')

output:-
RN Reddy IT School – Core Python

enter i value:6
enter j value:7
j is greaterthan i

if elif else:-
<syntax>
If <condition 1>:
Statement1
Elif<condition 2>:
Statement 2
Elif<condition 3>:
Statement2
Else
Statement4
Q) Comparing i and j by using if elif else
Output
Step 1:- design with output:
I=10 enter i value: 10
Step 2:- program
J=10 enter j value:10
i=int(input('enter i value:'))
j=int(input('enter j value:')) I is equal j
if i>j:
print('i is greaterthan j')
elif j>i:
print('j is greaterthan i')
else:
print('i is equal to j')
output:-
enter i value:10
enter j value:10
i is equal to j

Q) Write a python program to accept from the user display status


Step 1:-
Age output
1. Age >=58 senior citizen
2. Age 25 to 37 working citizen 58 enter your age : 58
3. Age 16 to 24 college student
Senior citizen
4. Age 4 to 15 school kid
5. Age 1 to 3 playing kid
6. Invalid age
RN Reddy IT School – Core Python

Program:-

age=int(input('enter your age: '))


if age>=58:
print('senior citizen')
elif age>=25:
print('working citizen')
elif age>=16:
print('college student')
elif age>=4:
print('school kid')
elif age>=1:
print('playing kid')
else:
print('invalid age')
Output:-
enter your age: 56
working citizen
Q) Write a python program to accept 3 subject marks M1 M2 M3 calculate total marks store in a variable
call total marks and calculate average marks into another variable called average marks display the result

 If I got less than 35 in any one subject he is fail


 if you get average marks greater than or equal to 60 he is in first class
 if average marks 50 - 59 in second class
 if the average marks between 35 to 49 marks in 3rd class

step 1 :- design with output output

M1=60 enter m1 marks:60

M2=70 enter m1 marks:70

step2:- M3=80 enter m1 marks:80

program Result is first class

m1=int(input('enter m1 marks:'))
m2=int(input('enter m2 marks:'))
m3=int(input('enter m3 marks:'))
totmarks=m1+m2+m3
avgmarks=(m1+m2+m3)/3
if m1<35 or m2<35 or m3<35:
print ('result is fail')
elif avgmarks>=60:
print('result is first class')
RN Reddy IT School – Core Python

elif avgmarks>=50:
print('result is second class')
else:
print('result is third class')

output:-

enter m1 marks:54

enter m2 marks:54

enter m3 marks:84

result is first class


RN Reddy IT School – Core Python

MULTIPLE IF

<syntax>
If <condition 1>:
Statement1
If <condition 1>:
Statement1
Step 1 :- program

i=int(input('enter i value:'))
j=int(input('enter j value:'))
if i>j:
print('i is greaterthan j')
if i<j:
print('j is greaterthan i')
if i==j:
print('j is equal to i')

Q) When we will go for simple if ?

A) Whenever we have an option which we want to execute based on condition we will go


for simple if

Q) When will go for if else ?

A) Whenever we have to option among two options if you want to execute one option
based on condition will go for if else

Q) When will go for if elif ?

A) Whenever we have more than two option if you want to execute an option based on
condition will go for if elif

Q) When will go for multiple if ?

A) Whenever we have more than two option if you want to execute every option based on
one condition will go for multiple if
RN Reddy IT School – Core Python

Nested if

Implementing if else within if else or if with if else or if elif else with if else and so on is
called as nested if

Implementing comparing ING by using nested if

i=int(input('enter i value:'))
j=int(input('enter j value:'))
if i>j:
print('i is greaterthan j')
else
if i<j:
print('j is greaterthan i')

else i==j:
print('j is equal to i')

Q) Accepting 3 subjects m1 m2 m3 and display the student result by using nested if

Step 1 :- program

m1=float(input('enter m1 marks:'))
m2=float(input('enter m2 marks:'))
m3=float(input('enter m3 marks:'))
totmarks=m1+m2+m3
avgmarks=(m1+m2+m3)/3
if m1<35 or m2<35 or m3<35:
print ('result is fail')
else:
if avgmarks>=60:
print('result is first class')
elif avgmarks>=50:
print('result is second class')
else:
print('result is third class')
RN Reddy IT School – Core Python

Loops:-

What we can do by using loops using loops we can execute a single statement are multiple
statements more than one time.

Q) When will go for loops?

A) Whenever you want execute a single statement on multiple statements more than one
time.

Types of loops

In python we can implement following types of loops follow.

 for loop
 while loop
 for loop with else
 while loop with else
For loop :-

<SYNTAX>

For<variable> in range (<startingrange>,<ending range>)

Q) Write a python program to print 1 to 4 by using for loop

Program
I output
for i in range(1,5): 1
print(i)
2

I output
Q) Write a python program to print 4 to 1 by using for loop
4
Program
3
for i in range(5,0,-1):
print(i) 2

1
RN Reddy IT School – Core Python

Q) Write a python program to print odd number like

Program I output

for i in range(1,10): 1
if i%2!=0:
3
print(i)
5

I output

Q) Write a python program to print odd number like 10

Program 20

for i in range(10,0,-1): 30
print(i)
40

50

I output
Q) Write a python program to print odd number like
10
Program
8
for i in range(10,0,-1):
6
if i%2!=0:
print(i) 4

While loop:-

<syntax>
While <condition>
<logic>
Q) Write a python program to print 1 to 4 by using for loop

Program I output

i=1 1
while i<=5:
print(i) 2
i=i+1 3

4
RN Reddy IT School – Core Python

Q) Write a python program to print 1 to 4 by using for loop

Program I output

i=5 4
while i<=1:
print(i) 3
i=i-1 2

Q) When we will go for “for loop”?

A) Whenever the numbers of iterations are fixed go with for loop.

Example: - printing 125 numbers.

Q) When we will go for while loop?

A) The number of iterations are not fixed go with while loop.

Example: - divide by zero error programs.

Q) Write a python program to print 1-5 number like below

Program I output

for i in range(1,6): 12345


print (i,end="")

Q) Write a python program to print


I output
Program:-
1
i=1
3
while i<=9:
print(i) 5
i=i+2
7
RN Reddy IT School – Core Python

program:- output

for i in range(10): 0123456789

print(i,end=””)

Q) Write range (10): whenever we will give a single value for range function the range will take it is a
ending range but it will iterate ending range -1

Write output for code below:-


10 9 8 7 6 5 4 3 2 1
for i in range (10,0,-1):

print(i,end=””)

write output for code below:-


10 20 30 40 50 60 70 80 90
for i in range (10,100,10):

print(i,end=””)

Nested loop :-
Implementing loop within the loop is called as nested loop

Q) Write a python program to print below output

1
Code: for i in range(1,6):
22 for j in range(i):
print(i,end="")
print()
333

4444

55555
RN Reddy IT School – Core Python

TRACING:-

Q) Write a python program for given below?

22
Code:-
333
for i in range(1,8):
4444 for j in range(i):
print(i,end="")
print()
55555

666666

7777777

Q) Write an Example to handle divide by zero error by using while loop:

a=int(input('enter first number: ')) Output


b=int(input('enter second number: '))
A=10 enter first number : 10
while b==0:
b=int(input('enter second number otherthan zero.....'))B=0 enter second number :0
c=a/b
print('div result is ',c) 0 pls enter second number
otherthan zero

0 pls enter second number


otherthan zero

5 division result is 2
RN Reddy IT School – Core Python

Q) Implement the following task by using while loop

1
Code:-
22
i=1
333 while i<=5:
j=1
while j<=i:
4444 print(i,end="")
j=j+1
55555 print()
i=i+1

55555 Code:-

4444 i=5
while i>=5:
333 j=1
while j<=i:
22 print(i,end="")
j=j+1
print()
1
i=i-1

Code:-
12345
i=5
1234 while i>=1:
j=1
while j<=i:
123 print(j,end="")
j=j+1
12 print()
i=i-1
1

12345
Code:-
1234
n=int(input('enter your range :'))
i=n
123 while i>=1:
j=1
12 while j<=i:
print(j,end="")
1 j=j+1
print()
i=i-1
RN Reddy IT School – Core Python

Q) Write a python program to print list of even numbers within the range

Step 1 :-design output


N output
Step 2 :-code
10 enter your range : 10
n=int(input('enter your range'))
for i in range(2, n+1): 2 4 6 8 10
if i % 2 == 0:
print(i, end = " ")

step 3:- Tracing

Q) Write a python program to check wheather the given number is prime or not

Step 1 :-

Design with output N output

Step 2:- 5 enter your number: 5

Program It is a prime number

num=int(input('enter your number: '))


if num > 1:
for i in range(2, num):
if (num % i) == 0:
print(num, "is not a prime number")
break
else:
print(num, "is a prime number")
else:
print(num, "is not a prime number")
RN Reddy IT School – Core Python

STEP 3:- TRACING

Q) Write a python program to accept two numbers implement swapping

output
Step1:- design output
a enter a value: 10
Step 2:- program
b enter b value: 5
a=int(input('enter a value: '))
b=int(input('enter b value: ')) a value is 5
a,b=b,a
b value is 10
print('a value is ',a)
print('b value is ',b)

output:-

enter a value: 10
enter b value: 5
a value is 5
b value is 10

Q) Write a python program to accept a string and print in reverse

Output
Step1:- design output
Enter your string : rama
Step 2:- program
Reverse string: amar
str1=input('enter your string: ')
print('reverse string :', str1[::-1])
RN Reddy IT School – Core Python

Q) Write a python program to display fibbanoic series upto given range

Step1:- design output

Step 2:- program


N output
n = int(input("enter your range: "))
01123
n1, n2 = 0, 1
count = 0
if n <= 0:
print("Please enter a positive integer")
elif n == 1:
print("Fibonacci sequence upto",n,":")
print(n1)
else:
print("Fibonacci sequence:")
while count < n:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1

For with else:-

Generally else part will be there for only conditional statements but in python else part is
available for loops

SYNTAX:-

For <variablenmae> in range(<first range> , <last range>)

//logic

Else

//logic

Note:- In this concept "for"block will execute as per number of iterations but "else" will
exit only one time in any case for loop is terminated by using break then else will not
execute
RN Reddy IT School – Core Python

Q) Write an Example to variable the atm pin by using for with else

Step :- design output

Step :- programm

for i in range(1,4):
pin=int(input('enter your pin'))
if pin==1122:
print('valid pin')
break
else:
print ('you entered pin is wrong')

While with else:-

<syntax>

While<condition>

// logic

Else:

//logic

Implementing valid pin example by using while with else

i=1
while i<=3:
pin=int(input('enter your pin'))
if pin==1122:
print('valid pin')
break
else:
print ('you entered invalidpin is your account is blocked')

Q) When will go loop with else?

A) Whenever you want implement else part for loop

Transfer statement

Using transfer statement we can transfer the program control from one place to another
place
RN Reddy IT School – Core Python

Q) When will go for transfer statement?

 whenever you want to transfer the program control


 from one place to another place
In python we have three types of transfer statement

 Break
 Continue
 pass
Break:-

Break will transfer the program control out of the loop

Write a python program to print 1 to 10 numbers but output should be like below
output
for i in range(1,11):
print(i) 1
if i==6:
2
break
3
Q) When we will go for break?
4
A) Whenever we want to transfer control out of the loop 5

Continue:-

Continue will skip the current iteration of the loop Output

Write a python program to print 1 to 10 numbers output should be like below 1

Step : program 2

i=8 4
for i in range(1,8):
if i==5: 6
continue
7
print(i)
RN Reddy IT School – Core Python

Q) When we will go for continue?

A) When our want to skip the current iterations then we will go for continue

Pass:-

 using pass we can pass from one block to another block


 this pass we will be used specially at the time of functions

String handling:-

string is a collection of character and string should enclosed with quotes

in python as per quotes in three types

 Single quoted string


Ex :- a=’rama’

 Double quoted string


Ex :- a=”rama”

 Triple quoted string


Ex :- a=’”rama’’’

Q) What is the difference between single double and triple quoted string?

A) Single quoted string and double quoted string with only single line but triple quoted
string will allow multiple lines.

Programming by using string function


Write a python program to accept a string and print length of the string

Step:- program
output
str1=input('enter the string: ')
print('length of string is : ', len(str1)) Rama Enter the string:

Length of your string is : 4


RN Reddy IT School – Core Python

List of strings function by using spring programming

str1=input('enter the string: ')


print(str1.isupper())
print(str1.islower())
print(str1.upper())
print(str1.lower())
print(str1.isalnum())
print(str1.isalpha())
print(str1.capitalize())

Example to understand some more string functions

str1=input('enter the string: ')


print(str1.count('a'))
print(str1.startswith('r'))
print(str1.endswith('a'))
print(str1.index('m'))
print(str1.find('m'))
print(str1.isalpha())
print(str1.isdigit())
str2=input('enter the string: ')
print(str2.split())
print(str2[3])
List all the string function with one line explanation on with one example

Len():- it will return number of characters within string

For example :

str1=‟rama‟
print(len(str1))

output:

Isupper :- it will write letter in capital letter in full show true otherwise small letters will be
show false

For example :-

str1=‟rama‟
print(str1.isupper())

output:-
RN Reddy IT School – Core Python

true
Lower:- it will write small letter it will show true otherwise capital later it will show false

For example :-

str1=‟rama‟
print(str1.islower())

Output:-
false

Upper () :- it will write letters in small then it will convert capital letters

For example :-

str1=‟rama‟
print(str1.upper())

Output:-

RAMA

Lower:- it will written letters in capital or small then it will convert to small letters

For example :-

str1=‟rama‟
print(str1.lower())

output:-
rama
isalnum():- it will take alphabets and numerical values it will come true otherwise false

For example :- For example :-

str1=’rama’
str1=‟123‟ print(str1.upper())
print(str1.isalnum())
output:-
True
output:-
True

Capitalize():- it will return first letter of the given string as a capital letter

For example :-

str1=‟rama‟
print(str1.capitalize())
RN Reddy IT School – Core Python

output:-
RAMA
Count:- it will return number of occurrence of a given character in a string

For example :-

str1=’rama’
print(str1.count(“a”))

output:-
2

Starts with () :- it will return the Boolean values and character it will check whether a
given character in starting letter or not

For example :-

str1=‟rama‟
print(str1.startwith(“r”))

output:-
True

Ends with ():- it will return the Boolean value it will set the weather given character is
ending letter or not

For example:-

str1=‟rama‟
print(str1.endswith(a))

output:-
True

Find ():- it will find the position of the given character

For example :-

str1=‟rama‟
print(str1.find(m))

output:-
2
RN Reddy IT School – Core Python

Centre():- it will move the number of position


For example :-
str1=‟rama‟
print(str1.center(20))

output:-
………….rama………..

Isalpha():- it will check whether the given string is alphabet or not


For example :-
str1=‟rama‟
print(str1.isalpha())

output:-
True

Isdigit():- it will check whether the given character is numeric or not


For example :-
str1=‟123‟
print(str1.isdigit())

output:-
True
Index():- it will give the index value of a given character
For example :-
str1=‟rama‟
print(str1.index(“m”))

output:-
2
RN Reddy IT School – Core Python

Split():- it will Speed the given string into words and store it as an array with single quote
For example :-
str1=‟rama and sita‟
print(str1.upper())

output:-
[“rama” ,‟and‟,‟sita‟]

Collections Data types:-

Collection is representing collection of elements

In python there are five types of collections

 List
 Tuple
 Set
 Frozenset
 Dictionary
List:-

 list is a collection of elements objects every element will be representing with 1


index value
 First element index value will be zero
 Second element index value will be 1
 List is a presenting with square bracket and comma separated values

EXAMPLE of lists :-
Empnames=[“rama” ,‟and‟,‟sita‟]

 Whenever we want to access an element of list you should access with the help of
index value like below
Empnames*0+ , will display ‘rama’
 List is a mutable value
RN Reddy IT School – Core Python

Q) What is a mutable object?

A) A mutable object can be changed with this we can say list values can be changed

Example :- empnames*1+=’rani’

 List collection follows both homogenous and heterogeneous elements


 Homogenous elements means similar type of elements
Example:-list1=[10,20,30,40,50]
 Heterogeneous elements means dissimilar type of elements
Example:-list1=*10,20,’rama’,’lata’+
 In list duplicate elements are allowed
Example:-list1=[10,20,30,30,40,40,40,50]
 List insertion order is preserved

Programming by using list:-

Q) Write a python program to create a list of collections print

Step 1:-design with output:

10 20 30 40 50 output
0 1 2 3 4
[10,20,30,40,50]

Step 2 :- code

mylist=[10,20,30,40,50]
print(mylist) output

10
Q) implement the above line by using loop
20
mylist=[10,20,30,40,50]
30
for I in mylist:
print(i) 40

50

Q) Print elements within the same line by using loop


output
mylist=[10,20,30,40,50]
for I in mylist: [10,20,30,40,50]
print(i,end=‟‟)
RN Reddy IT School – Core Python

Q) Printing the list of elements in reverse order

Output
mylist=[10,20,30,40,50]
for I in mylist: [50,40,30,20,10]
print(:: , -1)

Accepting the number from the user and appending list and display

Step 1:- program

mylist=()
for i in range (1,6):
j=int(input('enter a number: '))
mylist.append(j)
print(mylist)

step2:- Tracing

In above example print elements also by using for loop

Step1:- program

mylist=()
for i in range (1,6):
j=int(input('enter a number: '))
mylist.append(j)
print('mylist elements are : ')
for i in mylist:
print(i,end='')

step2:- Tracing
RN Reddy IT School – Core Python

Observation on list by using list method


Index ():- this method will return index value of a given element

For example :-

mylist=[10,20,30,40,50]
print(mylist.index(10))

Output:-

10

Eval():- This method will accept the elements from the user and store it into a list

For example :-

mylist=eval(input(enter a element of list))


print(mylist)

Output:-
input = [10,20,30,40,50]
[10,20,30,40,50]

NOTE:- eval() will convert the accepted value into list format

Append():- This method will be adding given element as last element to the list collection

For example :-

mylist=[10,20,30,40,50]
mylist.append(60)
print(mylist)
output:-

[10,20,30,40,50,60]

Extend():- This method will insert the multiple elements to the list at the time at last

For example :-

mylist=[10,20,30,40]
mylist.extend([40,50,60,70])
print(mylist)
output:-

[10,20,30,40,50,60,70]
RN Reddy IT School – Core Python

Remove():- it will remove the given element

Pop():- deleting last element from list

Pop < index value> :- deleting an element based on index

Example for remove() pop() methods

For example :-

mylist=[10,20,30,40,50]
mylist.remove(60)
print(mylist)

output:-

[10,20,30,40,50]

For example :-

mylist.pop()
print(mylist)
print(„pop elements based on index : , mylist.pop(2))

output:-

[10,20,30,40,50]

Pop elements is :50

Pop elements based on :40

Dell():- deleting multiple elements from a list by specifying an index

For example :-

mylist=[10,20,30,40,50]
dell mylist[1:3]
print(mylist)

output:-

[10, 30 ,50]
RN Reddy IT School – Core Python

Example to understand multiple methods of list

For example :-

mylist=[10,20,30,40,50]
mylist.reverse()
print(„reverse elements are: „ , mylist)

output:-

reverse elements are: [50,40,30,20,10]

For example :-

mylist=[10,20,30,40,50]
mylist.sort()
print(„sorted elements are: „ , mylist)

output:-

sorted elements are : [10,20,30,40,50]

For example :-

mylist=[10,20,30,40,50]
mylist.copy()
print(„copied elements are: „ , mylist)

output:-

copied elements are: [10,20,30,40,50]

Example for concatenation comparison creation of nested list

list1=[10,50,20,25,40]
list2=[100,10,2000,30,40]
mylist=list1+list2
print(mylist) #concatination
print(list1==list2) #comparision
mylist=[100,200,300,400,[500,600,700]] #nestedlist
print(mylist)
output:-

[10, 50, 20, 25, 40, 100, 10, 2000, 30, 40]
RN Reddy IT School – Core Python

False

[100, 200, 300, 400, [500, 600, 700]]

Tuple:-

 Is a collection of objects
 It is represented with comma to separate values
 It is an immutable object
 An immitable object cannot be changed
 In tuple insertion order is preserved
 Every element on tuple can be accessed within index number
 Nested tuple can also be created
 A tuple is in another tuple is called nested tuple
Syntax of tuple:

< tuple.name>=(value1,value2,.........value n );

Example of tuple;

Empnames=(‘raju’,’rani’)

Q) Example to create one tuple by displaying the elements

Step 1:-design with output:

10 20 30 40 50 output
0 1 2 3 4
[10,20,30,40,50]

Step 2 :-

Empno=(10,20,30,40,50)

Print(empnos)
RN Reddy IT School – Core Python

various operations on tuple

Tuple():- this function will convert list items into tuple


Example :-
Step1:- program
mylist=[10,20,30,40,50]
mytuple=tuple(mylist)
print(mytuple)

step2:- output
(10, 20, 30, 40, 50)
Len():- it gives the number of elements in Tuple

Count():- this function returns the number of occurrence of a given elements in to tuple
Example:-
Step1 :- program
mylist=[10,20,30,40,50]
print(mylist.count(20))

step2:- output
3
Index():- this method will return the index value of a given element
Example:-
Step1 :- program
mylist=[10,20,30,40,50]
print(mylist.index(20))

step2:- output
1
RN Reddy IT School – Core Python

Min() or max():-

Example:-

Step1 :- program

mylist=[10,20,30,40,50]
print(„minimum value is : „,min(mylist))
print(„maximum value is : „,max(mylist))

step2:- output

minimum value is: 10

maximum value is : 40

Eval() :- it will convert the given accepted value from string type to tuple

Example :-

my tuple=eval(input(‘enter your elements’)

print(mytuple)

output:-

enter your elements : 10,20,30,40,50,

(10,20,30,40,50)

Q) What is the difference between list and tuple

List Tuple
 list is immutable  Tuple is immutable
 list order is not fixed  Tuple order is fixed
 we can insert an element into list as  we can insert an element in data file
a middle element as last element
RN Reddy IT School – Core Python

Set:-

 Set is a collection of object


 set is represented with {and with, separated values
 Set does not support index
 Set is mutable collection
 on mutable collection we can do changes
Various operation on set collection with built in method:-

Set():- this method will convert the list items to set

Example:-

Step1:- program

myset=[10,20,30,40,50]
myset=set(myset)
print(myset)

step2:- output

{40, 10, 50, 20, 30}

Copy():- this method will copy the elements from one set to another set

Example:-

Step1:- program

myset=[10,20,30,40,50]
myset=myset.copy()
print(myset)

step2:- output

{50,20,40,10,30,}

Clear():- clear the list


RN Reddy IT School – Core Python

Unions of set:-

Example:-

Step1:- program

set1={10,20,30,40,50}
set2={60,70,80,90,100}
set3=set1.union(set2)
print(set3)

step2:- output

{100, 70, 40, 10, 80, 50, 20, 90, 60, 30}

Insertion of set():- this method is used to take common elements from two sets

Example:-

Step1:- program

set1={10,20,30,40,50}
set2={10,70,40,90,100}
set3=set1.intersection(set2)
print(set3)

step2:- output

{40, 10}

Frozen set:-

 Frozen set is a collection of objects


 Frozen set is a same as set but with one difference
 Frozen set is immutable object but where are set is mutable
Frozen set():-

Example:-

Step1:- program

mylist=[10,20,30,40,50]
myfrozenset=frozenset(mylist)
RN Reddy IT School – Core Python

print(myfrozenset)
print(type(myfrozenset))

step2:- output

frozenset({40, 10, 50, 20, 30})

<class 'frozenset'>

 This method will convert the given list item to frozen set
 Which method will convert any collection of to frozenset

Copy():- using this method we can copy the elements from one frozen set to another
frozenset

Example:-

Step1:- program

frozenset1=frozenset({1000,2000,3000,4000})
myfrozenset=frozenset1.copy()
print(myfrozenset)

step2:- output

frozenset({1000, 4000, 3000, 2000})

Union():- this method will join the two frozenset values into store in 1 frozenset

Example:-

Step1:- program

frozenset1=frozenset({1000,2000,3000,4000})
frozenset2=frozenset({50,60,40,70,80})
myfrozenset=frozenset1.union(frozenset2)
print(myfrozenset)

step2:- output

frozenset({4000, 70, 1000, 40, 2000, 80, 50, 3000, 60})


RN Reddy IT School – Core Python

Insertion():- this method will store the common values from two frozenset into third
frozenset

Example:-

Step1:- program

frozenset1=frozenset({50,2000,70,4000})
frozenset2=frozenset({50,60,40,70,80})
myfrozenset=frozenset1.intersection(frozenset2)
print(myfrozenset)

step2:- output

frozenset({50, 70})

Dictionary

 dictionary is a collection of key value pairs


syntax for dictionary:
<dict-name>={key:value}

Example
<emp_dict>={empname:raju}

 Dictionary are mutable that means we can do changes to dictionaries

Len():- this method will return the number of pairs with in the dictionaries

Keys():- function is used to display keys of dictionary

Example:-

Step1:- program

fruitsdict={111:'apple',222:'banana'}
print(fruitsdict.keys())

step2:- output

dict_keys([111, 222])
RN Reddy IT School – Core Python

Values():- values function is used to display values of dictionary

Example:-

Step1:- program

fruitsdict={111:'apple',222:'banana'}
print(fruitsdict.values())

step2:- output

dict_values(['apple', 'banana'])

module

function function variable classes


RN Reddy IT School – Core Python

Python Operators
Operators are used to perform operations on variables and values.

Python divides the operators in the following groups

 Arithmetic operators
 Assignment operators
 Arithmetic Assignment operators
 relational operators
 Logical operators
 Membership operators
 Identity operators
 Bitwise operators
 Bitwise Assignment operators

Assignment operators :- an assignment operator is used to assign a value to


variable

Syntax:<variable>=<value>

Example : a=10
RN Reddy IT School – Core Python

Arithmetic operators:-

Arithmetic operators are used with numeric values to perform common


mathematical operations

Operator Name Example

+ Addition x+y

- Subtraction x–y

* Multiplication x*y

/ Division x/y

% Modulus x%y

** Exponentiation x ** y

// Floor division x // y
RN Reddy IT School – Core Python

Arithmetic Assignment operators:- an arithmetic assignment operation performs


both arithmetic and assignment

Operator Example Same As

+= x += 3 x=x+3

-= x -= 3 x=x–3

*= x *= 3 x=x*3

/= x /= 3 x=x/3

%= x %= 3 x=x%3

//= x //= 3 x = x // 3

**= x **= 3 x = x ** 3
RN Reddy IT School – Core Python

Relational operators

Relational operators check a condition and return a Boolean value

1. Less than → used with <

2. Greater than → used with >

3. Equal to → used with ==

4. Not equal to → used with !=

5. Less than or equal to → used with <=

6. Greater than or equal to → used with >=

Logical operators

Logical operators are used to combine conditional statements:

And logic operator:-

And logical operator returns true when all given condition are true otherwise

returns false

OR logic operator

Or logical operator returns true if at least one condition is true within in given

condition otherwise returns false

Not logic operator

Not(true)=false

Not(false)=true
RN Reddy IT School – Core Python

Membership operators

Membership operator is used to check whether the given member is


existed or not

If existed true otherwise false

 In
 Notin

Example:-empnames=[‘raju’,’rajesh’,’suresh’]

‘raju’ in empnames

Output is = true

Example: - rajesh not in empnames

Output is= true

Identity operators

Identity operators return true if multiple objects have same id otherwise


return false

The following are identity operators

 Is
 Isnot

Example:-a=b=1000

A is b

o/p:- true
RN Reddy IT School – Core Python

Bitwise operators

Bitwise operators are used to perform operations on bit

The following below

AND Bitwise operators


&

OR Bitwise operators
|

XOR Bitwise operators


^

NOT Bitwise operators


~

left shift Bitwise operators


<<

right shift Bitwise operators


>>
RN Reddy IT School – Core Python

Program

 10&20--------(and)-------------------- o/p=0

 10/20--------(or) ---------------------o/p=30

 10^20--------(xor) --------------------o/p=30

 10>>20-------(rightshift)------------ o/p=40

 10<<20--------(leftshift)--------------o/p=40

Bitwise Assignment operators

 a=10
B=20
A&=b ----meaning a=a&b

o/p = 0

 a=10
B=20
A/=b ----meaning a=a/b

o/p = 30

 a=10
B=20
A>>=b ----meaning a=a>>b

o/p = 2

 a=10
B=20
A<<=b ----meaning a=a<<b
o/p = 40
RN Reddy IT School – Core Python

step1: Open Internet Browser -> go to www.python.org


step2: Select / Click on downloads
 Select Windows
 Click on Latest Python 3 Release - Python 3.8.0
 It will open next page & Go to end of the page...
 Click on Windows x86-64 executable installer
 With this Download process will start..
 Once download complete select the downloaded file
 It will open python window and (click on "Run" button)
 Click on "Add Python 3.8 to PATH" check box
step3: Click on "Customize Installation"
 It will open "Optional Features window", Click on the "Next" button
 It will open” Advanced Options” window, Here select “Customize Install
Location” and change that path name as “C:\Python38”
 Click on "Yes" button, Now Installation will start....
 Once Installation completed then Click on the close button.
How to open Python IDLE: Start  All Programs  “Python 3.8”  IDLE
RN Reddy IT School – Core Python

RN Reddy IT School
Online/Classroom Training’s

For more details contact


Cell: +91 9577146777, 9885199122,9866163990,9866193147
E-Mail:rnreddyitschool@gmail.com
Website: www.rnreddyitschool.co
FaceBook Group: https://www.facebook.com/groups/rnreddytechsupports
FaceBook Page: https://www.facebook.com/groups/reddyitschool
Youtube Channel:- https://www.youtube.com/c/RNREDDYITSchool

You might also like