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

Python Programmes

The document contains a list of programming problems and exercises related to lists, loops, patterns, and basic math/logic operations in Python. It includes tasks like creating and manipulating lists, calculating sums and averages, reversing numbers, checking for palindromes and Armstrong numbers, printing patterns, and simple menu-driven calculators.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Python Programmes

The document contains a list of programming problems and exercises related to lists, loops, patterns, and basic math/logic operations in Python. It includes tasks like creating and manipulating lists, calculating sums and averages, reversing numbers, checking for palindromes and Armstrong numbers, printing patterns, and simple menu-driven calculators.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 36

[1] Create a list of the following numbers and print them with their index.

[2] Create a list of your friends names and print them.

[3] Create a list of height of 5 students and print the list. (Use mixed
numbers integer and decimal both)

[4] Create a list of first letter of your friends names and print the list.

[5] Write some lines about “Bharat is best” and make list of words used
in the input.

[6] Create a list named friends and include elements like name, date of
birth, lucky number, favorite colour, weight, and height.

[7] Calculate the total number of zeros, positive and negative elements in
the list.

[9] Find out the difference between maximum and minimum elements of
the list.

[10] Arrange the elements of a list in increasing order of their value.

[11] Arrange the elements of a list in decreasing order of their value.

[12] Read a number from the keyboard and check whether the entered
number is present or not in the list. If present, then also print the
occurrences of a entered number.

[13] Find out the average of n elements.

[14] Find out the sum of each elements in the list.

[15] Find out the total number of even elements in the list.
[16] Find out the total number of odd elements in the list.

[17] Suppress all zero elements at the bottom of the list.

[18] Suppress all negative elements at the bottom of the list.

[19] Suppress all positive elements at the bottom of the list.

[20] Suppress all non-zero elements at the bottom of the list.

[21] Return the largest even number from the list, if there no even
number in the input, print “Even not found in the list”.

[22] Find the sum of even indexed elements from the list.

[23] Find the product of odd indexed elements from the list.

[24] Write a program to take in the roll number, name and percentage of
marks for n students of Class XI and do the following:

 Accept details of the n students (n is the number of students).


 Search details of a particular student on the basis of roll number and display
result.
 Display the result of all the students.
 Find the topper amongst them.
 Find the subject toppers amongst them.
You can use nested list.

[25] Create a list with some duplicate values and Remove all the
duplicates from the list.

[26] Create a list and check whether your list is having any element or
empty.
[27] Create a list and count the number of strings where the string length
is 2 or more and the first and last character are same from a given list of
strings.

[28] Create carbon copy of the list.

[29] Write a Python program to print a specified list after removing the
0th, 3rd and 5th elements.

Example: [2,3,4,5,6,7,8] then output will be [3,4,6,8]

[30] Print your list after removing all elements which are divided by 3.

1 Write a python program to find average and grade for given marks.

2 Write a python program to find the sale price of an item with a given cost and discount (%).

Write a python program to calculate perimeter/circumference and area of shapes such as


3
triangle, rectangle, square and circle.

4 Write a program to calculate Simple and Compound interest.

5 Write a program to calculate profit-loss for a given Cost and Sell Price.

6 Write a program to calculate EMI for Amount, Period and Interest.

7 Write a program to calculate tax – GST / Income Tax

8 Write a program to find the largest and smallest numbers in a list.

9 Write a python program to find the third-largest/smallest number in a list.

1
Write a program to find the sum of squares of the first 100 natural numbers.
0

1
Write a program to print the first ‘n’ multiples of a given number.
1

1
Write a program to count the number of vowels in a user-entered string.
2

1 Write a program to print the words starting with a particular alphabet in a user-entered
3 string.

1
Create a dictionary of students to store names and marks obtained in 5 subjects.
4

1
Create a dictionary to store the names of states and their capitals.
5
1. Reverse the entered number by printing the remainder.
2. Reverse the entered number. (Do not print the remainder)
3. Sum of each digit from a number.

4. Check no. is palindrome or not.

5. Check no. is Armstrong or not.

6. A series program: 1 4 9 16 25 36 and so on

7. Power of n starting with 1 3.

8. Find the factorial of n! 4. Factorial series

9. Sum of series

10. Conversion of a number

11. A menu Driven simple calculator

For loop based programs:

[12] Find average of list of numbers entered through keyboard.

[13] Take a number as input and check whether number is

[14] SUM = 1 + 4 – 9 + 16 – 25 + 36 – … and so on

[15] SUM = 12+22+32+42+52+62+72+.. and so on


[16] SUM = x – x3/3! + x5/5! – x7/7! + x9/9! -… and so on

[17] SUM = e1 +e2 +e3 +e4 +e5+… and so on

[18] SUM = 1 + 2 + 6 + 24 + 120 + … and so on

[19] SUM = 1 + 1/4 + 1/9 + 1/16 + 1/25 + and so on

[20] SUM = 1 + 8 + 27 + 64 + … and so on

[21] To print multiplication table from 1×1 to 10×10.

[22] To compute the sum of the digits of a given positive integer number.

[23] To read any five real numbers and print the average value.

[24] To calculate the sum of first N natural numbers.

[25] To calculate the average of first N odd numbers.

Pattern based programs

[27] 1 [28] 1

1 2 2 1

1 2 3 3 2 1

1 2 3 4 4 3 2 1

1 2 3 4 5 5 4 3 2 1

[29] 1 [30] 1

2 2 2 2
3 3 3 3 3 3

4 4 4 4 4 4 4 4

5 5 5 5 5 5 5 5 5 5

[31] 1 [32] 1

2 2 1 2

3 3 3 1 2 3

4 4 4 4 1 2 3 4

[33] 5 5 5 5 5 [34] a

4 4 4 4 b b

3 3 3 c c c

2 2 d d d d

1 e e e e e

[35] 5 4 3 2 1 [36] 1 2 3 4 5

5 4 3 2 2 3 4 5

5 4 3 1 2 3

5 4 1 2

5 1
[37] A B C D E [38] a b c d e

A B C D a b c d

A B C a b c

A B a b

A a

[39] a [40] *

a b * *

a b c * * *

a b c d * * * *

[41] 1 [42] * *

1 1 * * * *

1 2 1 * * * * * *

1 3 3 1 * * * * * * * *

1 4 6 4 1 * * * * * * * *

[43] * [44] * * * * *

* * * *

* * * * *
* * * * * *

* * * * *

* * * *

* * * * * *

[45] A [46] Z

A B Z Y

A B C Z Y X

A B C D Z Y X W

A B C D E Z Y X W V

A B C D E F Z Y X W V U

[47] A [48] Z

A B Z Y

A B C Z Y X

A B C D Z Y X W

A B C D E Z Y X W V

[49] 1 [50] 1

1 4 4 1
1 4 9 9 4 1

1 4 9 16 16 9 4 1

1 4 9 16 25 25 16 9 4 1

[51] 0 [52] 0

1 0 1 -1 0 1

2 1 0 1 2 -2 -1 0 1 2

3 2 1 0 1 2 3 -3 -2 -1 0 1 2 3

4 3 2 1 0 1 2 3 4 -4 -3 -2 -1 0 1 2 3 4

[53] A diamond pattern is formed with a given letter of the alphabet. Write a
program to generate and display such by accepting any character and total
number of lines (say N). Assume N is an odd number.

For example, if the accepted character is ‘V’ and N = 4, then your


program should display the following output :

V V

V V V

V V V V

V V V

V V
V

[54] A pattern is constructed by stacking up 3 basic triangles formed with


stars. The figure below shows each basic triangle having 3 layers of stars :

Python Loop Programs for


Class 11

[55] Generate the following “pyramid” of digits.

Pattern 2 Python Loop Programs for Class 11

[56] Find the value of the following formula : nCr = n!/(r! * (n-r)! )

[57] To find the value of the following formula : nPr = n!/(n-r)!


Create a dictionary named student and write a menu-driven program to do
the following:

1. Show record
2. Add new student
3. Delete a student
4. Search record
5. Update record
6. Sort record
7. Exit
Solution:

n=int(input("How many stduents:"))

std={}

for i in range(n):

print("Enter details of student:",i+1)

name=input("Enter name of student:")

pn=int(input("Enter Percentage:"))

std[name]=pn

c=0

while c!=7:

print('''

1. Show record

2. Add new student

3. Delete a student
4. Search record

5. Update record

6. Sort record

7. Exit

''')

c=int(input("Enter your choice:"))

if c==1:

for i in std:

print(i,":",std[i])

elif c==2:

print("Enter details of new customer:")

name=input("Enter name:")

pn=int(input("Enter Percentage:"))

std[name]=pn

elif c==3:

nm=input("Enter name to be deleted:")

f=std.pop(nm,-1)

if f!=-1:

print(f, " is deleted successfully.")

else:
print(f, " not found.")

elif c==4:

name=input("Enter Customer Name:")

if name in std:

print(name, " found in the record.")

else:

print(name, " not found in the record.")

elif c==5:

name=input("Enter Customer Name:")

pn=int(input("Enter percentage to modify:"))

std[name]=pn

elif c==6:

l=sorted(std)

for i in l:

print(i,":",std[i])

elif c==7:

break

else:

print("Invalid Choice")
S.No
Practical Program
.

1 Write a python program to input a welcome message and display it.

Write a python program to input two numbers and display the larger /
2
smaller number.

Write a python program to input three numbers and display the largest
3
/ smallest number.

4 Generate patterns using a nested loop.

Write a program to input the value of x and n and print the sum of the
following series:
5
1) 1 + x² + x³ + … + xⁿ
2) x – x2/2! + x3/3! – x4/4! + x5/5! – x6/6!

Write a program to determine whether a number is a perfect number,


6
an Armstrong number or a palindrome.

Write a program to input a number and check if the number is a prime


7
or composite number.

8 Write a program to display the n terms of a Fibonacci series.

Write a python program to compute the greatest common divisor and


9
least common multiple of two integers.

Write a program to count and display the number of vowels,


10
consonants, uppercase, lowercase characters in the string.
2 Write the following simple statements in python interactive mode and take a
screenshot of it including the output.

1. 11 + 67
2. 34 + 89 – 34
3. (24 / 2) + (89%4)
4. 11 * 5 – (22 * 2)
5. 25 ** 3 + (26 **3)
6. 23 // 5 % 2
7. 5 < 3
8. 8 > 13
9. 21 < 12 and 5 > 2 or a ==’A’
10.23 != 25 and 26 == 26
3 Write a statement to print your favorite poem in python. Use “\n” to print
the next line. (Without indentation)

4 Write a statement to print a table of 5 using “\t” and “\n”.

5 Write a python statement to repeat the word “Python” three times using a
variable and * operator.

6 Write a python statement to accept your first name, last name, and surname
in three variables and join them using print() function.

7 Write a python statement to display your name and address both in a single
line.

8 Write a statement to print your favorite poem command in python. Use “\n”
to print the next line with a proper indentation.

Write a python program to

Algebraic Expression

1. Solve these arithmetic/algebraic expressions.


1. 4x + 3y – 5
2. 4x2 − 5xy + 5
3. ut+1/2at2
4. x2 + y2
5. (a + b )2
Compute Areas
1. Compute areas of the following (Find the equation and implement in
python):
1. Circle
2. Square
3. Sphere
4. Triangle
5. Rectangle
Simple computations

1. Accept the total score, overs, and find the run rate.
2. Enter the details of 5 players, matches played, runs scored, and print them.
3. Enter two numbers and swap them without taking the temporary variable.
4. Enter a number and power then compute the power using an exponential
operator.
5. Enter two numbers and perform the floor division.
6. Enter two angles of a triangle and find the third angle.
7. Enter any three sides of a rectangle and find the fourth side.
8. Ask the user for the loan amount, rate of interest, and Find the no. of
installments for the year.
Shorthand operators

1. Accept a number, then do the following using shorthand operator:


1. Increment the number by 5
2. Decrement the number by 2
3. Multiply the number with 3
4. Divide the number by 4
Conversions

1. Enter a username, password, and print the message your account has been
created.
2. Enter the money in decimal form and separate them. For example, money
entered is: 100.75 then your output should be 100 Rs. 75 Paise.
3. Conversion programs:
1. Centimeter to Meter and Kilometer
2. Celcius to Fahrenheit
3. Fahrenheit to Celcius
4. Days into Years, Months and weeks
5. Grams to Kilograms
6. Milliliters to liters
4. Generate a series of 1 to n Numbers.
5. Develop a series of odd numbers from 1 to n.
6. Print a series of numbers divisible by 3 from 1 to n.
7. Create a series of square numbers from 1 to n.
8. Display all multiples of 4 starting from 11 to 100.
if-elif-else python exercises Class11

[1] The given number is odd or even.

def odd_even():

n = int(input("Enter any number:"))

if n % 2!=0:

print("No is odd")

else:

print("No is even")

odd_even()

[2] The given number is positive or negative or zero.

def pnz_check():

n = int(input("Enter any number:"))

if n>0:

print("No is positive")

elif n<0:
print("No is negative")

else:

print("Zero")

pnz_check()

[3] The given number is of one digited or two digited or three digited or more
than three digited.

def dig_check():

n = int(input("Enter any number:"))

if n>0 and n<10:

print("One digit number")

elif n>10 and n<100:

print("Two digit number")

elif n>100 and n<1000:

print("Three digit number")

else:

print("More than three digit number")

dig_check()

[4] The entered number is smallest 4 digit number or not.

def smallest4digit():

n = int(input("Enter any number:"))


if n==1000:

print("n is smallest 4 digit no")

else:

print("n is not a smallest 4 digit no")

smallest4digit()

[5] The given character is an uppercase letter or lowercase letter or a digit or a


special character.

def check_chr():

ch = input("Enter a character to check:")

if ord(ch)>=65 and ord(ch)<=90:

print("The character", ch, " is an uppercase letter")

elif ord(ch)>=97 and ord(ch)<=122:

print("The character", ch, " is a lowercase letter")

elif ord(ch)>=48 and ord(ch)<=57:

print("The character", ch, " is a digit")

else:

print("The character", ch, " is a special chacracter")

check_chr()

[6] The given year is a leap year or not.

def check_leapyear():
year = int(input("Enter a character to check:"))

if (year%4==0 and year%100!=0) or (year%400==0):

print("Year is a leap year")

else:

print("Year is not a leap year")

check_leapyear()

[7] The given number is divisible by 5 or not.

def check_div5():

n = int(input("Enter a number to check:"))

if n%5==0:

print("No is divisible by 5")

else:

print("No is not divisible by 5")

check_div5()

[8] Find maximum number out of given three numbers.

def check_max3():

n1,n2,n3 = int(input("Enter no1:")),int(input("Enter


no2:")),int(input("Enter no3:"))

if n1>n2 and n1>n3:

print("No1 is maximum")
elif n2>n1 and n2>n3:

print("No2 is maximum")

elif n3>n1 and n3>n2:

print("No3 is maximum")

else:

print("All are equal")

check_max3()

[9] Find minimum number out of given three numbers.

Do it yourself.

Watch this video lesson explains the programms.

[10] Write a program that reads three positive numbers a, b, c and determines
whether they can form the three sides of a triangle.

def check_3tri():

a=int(input("Enter no1:"))

b=int(input("Enter no2:"))

c=int(input("Enter no3:"))

if(((a+b)<=c)or((b+c)<=a)or((c+a)<=b)):

print("It can not form the triangle")

else:

print("It can form the triangle")


check_3tri()

[11] Whether the triangle will be an obtuse-angle, or a right-angle or an


acute-angle triangle.

def check_tritype():

a=int(input("Enter no1:"))

b=int(input("Enter no2:"))

c=int(input("Enter no3:"))

square_a = a**2

square_b = b**2

square_c = c**2

if square_a == square_a + square_b or square_b == square_a + square_c


or square_c == square_a + square_b:

print("Right-angled Triangle")

elif square_a > square_c + square_b or square_b > square_a + square_c


or square_c > square_a + square_b:

print("Obtuse-angled Triangle")

else:

print("Acute-angled Triangle")

check_tritype()

[12] If the triangle is an acute angle triangle, determine further whether the
triangle is equilateral, isosceles, or scalene.

def check_tritype2():
a=int(input("Enter no1:"))

b=int(input("Enter no2:"))

c=int(input("Enter no3:"))

if a==b==c:

print("Equilateral triangle")

elif a==b or b==c or c==a:

print("isosceles triangle")

else:

print("Scalene triangle")

check_tritype2()

[13] A toy vendor supplies three types of toys: Battery Based Toys, Key-based
Toys, and Electrical Charging Based Toys. The vendor gives a discount of 10%
on orders for battery-based toys if the order is for more than Rs. 1000. On
orders of more than Rs. 100 for key-based toys, a discount of 5% is given, and
a discount of 10% is given on orders for electrical charging based toys of value
more than Rs. 500. Assume that the numeric codes 1,2 and 3 are used for
battery based toys, key-based toys, and electrical charging based toys
respectively. Write a program that reads the product code and the order
amount and prints out the net amount that the customer is required to pay
after the discount.

def compute_discount():

print("1. For Battery based Toys")

print("2. For Key based Toys")

print("3. Electric chargin based Toys")


opt = int(input("Enter the product code (1,2 or 3)?:"))

amt = int(input("Enter the amount:"))

if opt==1:

if amt>1000:

dis = amt * 0.1

else:

dis = 0

elif opt==2:

if amt>100:

dis = amt * 0.05

else:

dis=0

elif opt==3:

if amt>500:

dis = amt*0.1

else:

dis = 0

else:

print("Product is not available")

bill_amt= amt - dis


print("Customer has to pay:",bill_amt)

compute_discount()

[14] A function f is defined as follows :

f(x) = ax3 – bx2 + cx –d, if x > k

= 0, if x = k

= -ax3 + bx2 – cx +d, if x < k

Write a program that reads a, b, c, d, k and x and prints the value of f(x).

def sol14():

a = int(input("Enter a:"))

b = int(input("Enter b:"))

c = int(input("Enter c:"))

d = int(input("Enter d:"))

k = int(input("Enter k:"))

x = int(input("Enter x:"))

if x > k:

fx = a*(x**3) - b*(x**2) + c*x -d

if x ==k:

fx =0

if x < k:
fx = -a*(x**3) + b**x**2) - c*x + d

print(fx)

sol14()

[15] Write a program to do the following operations :

 Read any two positive integer numbers (say n1 & n2) and one character
type operator (say opr). Note that opr is any mathematical operator.
 Depending upon the operator, do the appropriate operation. e. g. if opr is
‘+’ then the display the value obtained by evaluating the expression (n1 +
n2).
def sol15():

n1 = int(input("Enter n1:"))

n2 = int(input("Enter n2:"))

print("+ for addition\n")

print("- for addition\n")

print("* for addition\n")

print("\ for division\n")

ch = input("Enter the choice:")

if ch=='+':

ans = n1 + n2

elif ch == '-':

ans = n1 - n2

elif ch == '*':
ans = n1 * n2

elif ch == '/':

ans = n1 / n2

else:

print("Invalid choice")

print("The answer is:",ans)

sol15()

Below you will find the list of application based program list for if-elif-
else python exercises Class11.

[16] The Paschim Gujarat Vij Company Ltd. computes the electricity bill based
on the following matrix:

Units Consumed Charges

0-100 0.50 per unit

101-200 Rs. 50 plus Rs. 1 per unit over 100 units

201-300 Rs. 150 plus 1.50 per unit over 200 units

> 300 Rs. 300 plus Rs.2 per unit over 300 units

1. Ask user to enter the Past meter reading and current meter reading.
2. Find the units consumed.
3. Compute the bill according to given matrix.
def sol16():

pmr = int(input("Enter past meter reading:"))

cmr = int(input("Enter current meter reading:"))


uc = cmr - pmr

if uc>0 and uc<=100:

bill_amt = uc * 0.50

elif uc>100 and uc<=200:

bill_amt = 50 + (uc-100) * 1

elif uc>200 and uc<=300:

bill_amt = 150 + (uc-200) * 1.50

else:

bill_amt = 300 + (uc-300) * 2

print("The bill amount is:",bill_amt)

sol16()

[17] A cloth showroom has announced the following discounts on the


purchase of specific items :

Amount Shorts Pants Shits/T-Shirts

0-100 – 3% 5%

101-200 5% 8% 10%

201-300 10% 12% 15%

Above 300 18% 20% 22%

1. Ask user to enter the amount and assign following code for the items such
as sh for shorts, p for pans and sht for shirts/t-shirts.
2. Compute the discount and net amount paid by customer.
def sol17():

print("/'sh/' for Short")

print("/'p/' for Pants")

print("/'t/' for t-shirts")

opt = input("Enter the product code (/'sh/',/'p/',/'sht/')?:"))

amt = int(input("Enter the amount:"))

if opt=='s' opt=='S':

if amt>0 and amt<100:

dis = 0

elif amt>100 and amt<200:

dis = amt * 0.05

elif amt>201 and amt<300:

dis = amt * 0.1

else:

dis = amt * 0.18

elif opt=='p' opt=='P':

if amt>0 and amt<100:

dis = amt * 0.03

elif amt>100 and amt<200:

dis = amt * 0.08


elif amt>201 and amt<300:

dis = amt * 0.12

else:

dis = amt * 0.20

if opt=='t' opt=='T':

if amt>0 and amt<100:

dis = amt * 0.05

elif amt>100 and amt<200:

dis = amt * 0.10

elif amt>201 and amt<300:

dis = amt * 0.15

else:

dis = amt * 0.22

bill_amt = amt - dis

print("Customer has to pay:",bill_amt)

sol17()

[18] BSNL has three categories of customers: Industrial, Bulk Institutional and
Domestic. The rates for these are tabulated below :

Category Units Rate

Commercial Minimum up to 5000 units Rs. 1500


Next 5000 units Rs. 0.25 per unit

Next 10000 units Rs. 0.23 per unit

Above this Rs. 0.20 per unit

Institutional Minimum up to 5000 units Rs. 1800

Next 5000 units Rs. 0.30 per unit

Next 10000 units Rs. 0.28 per unit

Above this Rs. 0.25 per unit

Domestic Minimum up to 100 Units Rs. 75

Next 100 Units Rs. 1.25 per unit

Next 200 Units Rs. 2.00 per unit

Above this Rs. 2.50 per unit

1. Ask user to enter customer category, Units.


2. Compute the bill as per given criteria.
3. Print bill in proper format.
def sol18():

cat = input("Enter the category(commerical, institutional, or


domestic:")

units =int( input("Enter the units:"))

if cat == "commercial":

if units>0 and units<=5000:


bill = 1500

elif units>5000 and units<=10000:

bill = units * 0.25

elif units>10000 and units<=15000:

bill = units * 0.23

elif units>15000:

bill = units * 0.20

elif cat == "institutional":

if units>0 and units<=5000:

bill = 1800

elif units>5000 and units<=10000:

bill = units * 0.30

elif units>10000 and units<=15000:

bill = units * 0.28

elif units>15000:

bill = units * 0.25

if cat == "domestic":

if units>0 and units<=100:

bill = 75

elif units>100 and units<=200:


bill = units * 1.25

elif units>200and units<=300:

bill = units * 2

elif units>300:

bill = units * 2.50

print("*"*80)

print("The category:",cat)

print("Units:", units)

print("*"*80)

print("Bill amount:", bill)

sol18()

[19] A transport company charges the fare according to following table:

Distance Charges

1-50 8 Rs./Km

51-100 10 Rs./Km

> 100 12 Rs/Km

Ask user to enter the distance and compute the fare.

def sol19():

distance = int(input("Enter distance:"))


if distance>=1 and distance<=50:

fare = distance * 8

elif distance>=51 and distance<=100:

fare = distance * 10

elif distance>100:

fare = distance * 12

else:

print("Invalid fare")

print("The total fare is:",fare)

sol19()

[20] The Sardar Patel Cricket Stadium, Motera has the following rates for
different types of seats:

1. Ordinary – 2500
2. Pavillion – 3500
3. Upper Pavillion – 4500
4. Commentary Box – 6000
5. VIP – 8000
They are giving 10% discount for online booking and 8% discount for advance
booking and no discount is given for booking on match day from ticket
window.

1. Ask user to enter the booking type like online, advance or window booking.
2. Ask user to select the types of seats.
3. Compute the amount and print the ticket with proper format.
def sol20():

b_type = input("Enter booking type(online or advanced or window):")


s_type = input("Enter seat type(ordinary,pavallion,upper pavallion,
commentary box,VIP):")

nop = int(input("Enter no. of persons:"))

if s_type=="ordinary":

rate = 2500

elif s_type=="pavallion":

rate = 3500

elif s_type=="upper pavallion":

rate = 4500

elif s_type=="commentary box":

rate = 6000

elif s_type=="VIP":

rate = 8000

else:

print("Invalid Seat Types")

amt = nop * rate

if b_type=="online":

dis_per = "10%"

dis = amt * 0.1

elif b_type=="advanced":

dis_per = "8%"
dis = amt * 0.08

elif b_type=="window":

dis_per = "0%"

dis = 0

net_amt = amt - dis

print("-"*120)

print("\t\t\tSardar Patel Cricket Stadium - Motera, Ahmedabad")

print("-"*120)

print("Your Seats:",s_type,"\t Booking type:",b_type)

print("No of seats:",nop,"\t Amount (before discount):", amt)

print("-"*120)

print("Discount in (%):",dis_per,"\t Discount amount:",dis)

print("Bill amount is", net_amt)

sol20()

You might also like