0% found this document useful (0 votes)
13 views4 pages

GR 10 AI Practical

The document contains code snippets that accept user input and perform calculations: 1) Check if a character is a digit, uppercase, lowercase or special character. 2) Check if the first and last digits of a 4 digit number are equal or not and calculate sum or product. 3) Calculate sum of digits of a 4 digit number. 4) Find highest marks from subjects and display student name. 5) Calculate electricity bill based on units consumed.

Uploaded by

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

GR 10 AI Practical

The document contains code snippets that accept user input and perform calculations: 1) Check if a character is a digit, uppercase, lowercase or special character. 2) Check if the first and last digits of a 4 digit number are equal or not and calculate sum or product. 3) Calculate sum of digits of a 4 digit number. 4) Find highest marks from subjects and display student name. 5) Calculate electricity bill based on units consumed.

Uploaded by

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

Accept a character from user and check whether it is a digit, uppercase,

lowercase or special character?

ch = input("Enter a character: ")

if ch >= '0' and ch <= '9':

print("Digit")

elif ch.isupper():

print("Uppercase")

elif ch.islower():

print("lowercase")

else:

print("special character")

write a program to take 4 digit number from user and check first and last
digit is equal or not. If it is equal then calculate sum of both digits otherwise
product of both digits.

n = int(input("Enter four digit number"))

fd = n//1000

ld = n%10

if fd == ld:

print("First and last digit is equal, their sum is = ", fd+ld)

else:

print("First and last digit is not equal, their product is = ", fd*ld)
Accept a four digit number from user and calculate the sum of all the digits
of the number

num = input("Enter Number: ")

sum = 0

for i in num:

sum = sum + int(i)

print(sum)

write a program to accept student name and 4 subjects marks and display
the student name with highest marks.

name=input("enter name ")

math=int(input("marks of maths "))

phy=int(input("marks of physics "))

chem=int(input("marks of chemistry "))

bio=int(input("marks of biology "))

temp=math

if temp<=phy:

temp=phy

elif temp<=chem:

temp=chem

elif temp<=bio:

temp=bio

print (name ,"your higest score ",temp)


write a program to calculate the electricity bill. Accept the number of units
from user. Calculate it according to following.
Less than 100 units no charge
100-200 units Rs . 5 per unit
More than 200 units rs . 10 per unit
3% GST TO BE ADDED TO FINAL BILL.
units=0

charges=0

extracharges=0

extraunits=0

gst=0

tot=0

units=int(input("enter number of units "))

if units<100:

tot=0

elif units>=100 and units<=200:

charges=units*5

gst=charges*(3/100)

tot=charges+gst

else:

extraunits=units-200

charges=200*5

extracharges=extraunits*10

gst=(charges+extrachaarges)*3/100

tot= charges+extracharges+gst

print ("total cost =", tot)

You might also like