0% found this document useful (0 votes)
75 views7 pages

PYthon Class 11 Telugu

The document discusses Python control structures like decision statements (if, if-else, if-elif-else), looping statements (for, while), and transfer statements (break, continue, pass). It also discusses steps for software engineers to write code like defining the task, alternatives, choosing the best option, and writing code. Examples are provided of if-else, if-elif-else, and nested if statements to display student results, marks list with grades, and electricity bill based on unit usage.

Uploaded by

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

PYthon Class 11 Telugu

The document discusses Python control structures like decision statements (if, if-else, if-elif-else), looping statements (for, while), and transfer statements (break, continue, pass). It also discusses steps for software engineers to write code like defining the task, alternatives, choosing the best option, and writing code. Examples are provided of if-else, if-elif-else, and nested if statements to display student results, marks list with grades, and electricity bill based on unit usage.

Uploaded by

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

Python Class 11

-----------------------------

Control Structures
---------------------

1. Decision Statements
--> simple if
--> if..else
--> if..elif..else
--> Nested if

2. Looping Statements
--> For Loop
--> While Loop

3. Transfer Statements
--> Break
--> Continue
--> Pass

Software Engineers
~~~~~~~~~~~~~~~~~~~

Task
~~~~~~~~~~

1. Write down your task..What your task is


2. Write down all the possible to solve that task
3. Choose among all the alternatives and choose the best one
4. Write down the code

eg:

# Program to dsiplay student results

Marks Result
-------- ----------------

mpc>=35 Pass

--- Fail

htno=int(input("Enter Your Hall Ticket Number"))


nm=input("Enter Your Name:")
m=int(input("Enter Marks in Mathematics:"))
p=int(input("Enter Marks in Physics:"))
c=int(input("Enter Marks in Chemistry:"))

if(m>=35 and p>=35 and c>=35):


print(nm," Congratulations! You have Passed!")
else:
print(nm," Sorry! You have Failed")

eg:2

htno=int(input("Enter Your Hall Ticket Number:"))


nm=input("Enter Your Name:")
m=int(input("Enter Marks in Mathematics:"))
p=int(input("Enter Marks in Physics:"))
c=int(input("Enter Marks in Chemistry:"))

print("\n"*2)
print("--------------------STUDENT MARKS LIST-------------------")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("\n"*2)

print("Hall Ticket Number :",htno)


print("Name :",nm)
print("Marks in Mathematics:",m)
print("Marks in Physics:",p)
print("Marks in Chemistry:",c)

if(m>=35 and p>=35 and c>=35):


print(nm," Congratulations! You have Passed!")
else:
print(nm," Sorry! You have Failed")

print("\n"*2)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

If..elif..else
====================

It is also called as Ladder statements or Branching statements


It is used to execute the statements based on the given condition

Syntax:
~~~~~~~~~~

if(condition1):
statements
statements
elif(condition2):
statements
statements
elif(condition2):
statements
statements
.
.
.
else:
statements
statements

eg:

# Program to display the student Marks List with Grade

Marks Grade
--------------- -------------------------

MPC>=35 & avg>=75 Distinction

MPC>=35 & avg>=60 & avg<75 First Class

MPC>=35 & avg>=50 & avg<60 Second Class

MPC>=35 & avg>=35 & avg<50 Third Class

--------------- Fail

htno=int(input("Enter Your Hall Ticket Number:"))


nm=input("Enter Your Name:")
m=int(input("Enter Marks in Mathematics:"))
p=int(input("Enter Marks in Physics:"))
c=int(input("Enter Marks in Chemistry:"))
tot=m+p+c
avg=tot/3

print("\n"*2)
print("--------------------STUDENT MARKS LIST-------------------")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("\n"*2)

print("Hall Ticket Number :",htno)


print("Name :",nm)
print("Marks in Mathematics:",m)
print("Marks in Physics:",p)
print("Marks in Chemistry:",c)
print("Total Marks :",tot)
print("Average Marks :",avg)

if(m>=35 and p>=35 and c>=35 and avg>=75):


print("Grade = Distinction")

elif(m>=35 and p>=35 and c>=35 and avg>=60 and avg<75):


print("Grade = First Class")

elif(m>=35 and p>=35 and c>=35 and avg>=50 and avg<=60):


print("Grade = Second Class")

elif(m>=35 and p>=35 and c>=35 and av>=35 and avg<50):


print("Grade = Third Class")

else:
print("Grade = Fail")

print("\n"*2)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

eg:
# Program to display the Electricity Bill based on the given condition
Mtno, Name, PMR, CMR, Difference, Unit Charge, Total Amount

Difference Unit charge in Rupees


~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~

0-100 1

101-250 2

251-400 3

401-650 4

651-850 5

---- 7

mtno=int(input("Enter Meter Number : "))


nm=input("Enter Your Name : ")
pmr=int(input("Enter Your Previous Month Meter Reading : "))
cmr=int(input("Enter Your Current Month Meter Reading : "))

diff=cmr-pmr

if(diff>=0 and diff<=100):


uc=1
elif(diff>100 and diff<=250):
uc=2
elif(diff>250 and diff<=400):
uc=3
elif(diff>400 and diff<=650):
uc=4
elif(diff>650 and diff<=850):
uc=5
else:
uc=6

ta=diff*uc

print("\n"*2)
print("------------------------ELECTRICITY BILL----------------------")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("\n"*2)

print("Meter Number : ",mtno)


print("Name : ",nm)
print("Previous Month Meter Reading : ",pmr)
print("Current Month Meter Reading : ",cmr)
print("Difference : ",diff)
print("Unit Charge :",uc)
print("Total Amount : ",ta)

print("\n"*2)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
----------------------------------------------------------------------------

Nested if
~~~~~~~~~~~~~~~

It is also called as Multi Branching Statements


It is used to execute the statements based on the given condition
It is just similar to if..elif..else but the if block contains if..elif..else
and else block contains the if..elif..else

Syntax:
~~~~~~~~~~~

if(condition1):
if(condition1.1):
statements
statements
elif(condition1.2):
statements
statements
elif(condition1.3):
statements
statements
.
.
.
else:
statements
statements
else:
if(condition2.1):
statements
statements
elif(condition2.2):
statements
statements
elif(condition2.3):
statements
statements
.
.
.
else:
statements
statements

eg:
# Program to display the person details

Age Male Female


~~~~~ ~~~~~~~ ~~~~~~~~~

0-10 Kid Baby girl

11-20 Boy girl

21-30 Teenager Teenager(girl)


31-40 Youth Youth(woman)

41-50 Uncle Aunty

--- Senior Senior Citizen(Woman)


citizen

nm=input("Enter Your Name: ")


age=int(input("Enter Your Age: "))
type=input("Enter Your gender: ")

print("\n"*5)
print("----------------------AGE CALCULATOR-------------------------")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("\n"*2)

print("Name = ",nm)
print("Age = ",age)

if(type=="male"):
if(age>=0 and age<=10):
print(nm," You are a Kid and you are ",age," years old")

elif(age>10 and age<=20):


print(nm," You are a Boy and You are ",age," years old")

elif(age>20 and age<=30):


print(nm," You are a Teenager and You are ",age," years old")

elif(age>30 and age<=40):


print(nm," You are Youth and You are ",age," years old")

elif(age>40 and age<=50):


print(nm," You are Uncle and You are ",age," years old")

else:
print(nm," You are a Senior Citizen and You are ",age," years old")

else:
if(age>=0 and age<=10):
print(nm," You are a Baby girl and you are ",age," years old")

elif(age>10 and age<=20):


print(nm," You are a girl and You are ",age," years old")

elif(age>20 and age<=30):


print(nm," You are a Teenager(girl) and You are ",age," years old")

elif(age>30 and age<=40):


print(nm," You are Youth(Woman) and You are ",age," years old")

elif(age>40 and age<=50):


print(nm," You are Aunty and You are ",age," years old")

else:
print(nm," You are a Senior Citizen(Woman) and You are ",age," years
old")
print("\n"*2)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

You might also like