J

@jayanth_balamurugan_R

Write a Python program to get the smallest number from a list.

Python
2 years ago
list1=[6,43,5,7,34,6,34,64,4,6,65,23,1,4,54] list1.sort() print(list1[0])

python program to find the largest element in a list

Python
2 years ago
list1 = [12,43,67,4634,324,4] list1.sort() print(list1[-1])

Write a Python program to sum all the items in a list.

Python
2 years ago
list=[1,2,67,9,78] sum=0 for i in list: sum=sum+i print(sum)

loop in list

Python
2 years ago
cars=['audi','benz','bmw','porsche'] for i in cars: print(i) if (i=='benz'): break;

length func

Python
2 years ago
list=[1,2,3,4,5,6,7,4,2,2,4,5,6,4,3,3,3,2,3,5,5] print(len(list))

count func

Python
2 years ago
list=[1,2,3,4,5,6,7,4,2,2,4,5,6,4,3,3,3,2,3,5,5] print(list.count(3))

sum func

Python
2 years ago
list=[1,2,3,4,5] sum=sum(list) print("the sum of the list is:",sum )

insert func

Python
2 years ago
numbers=[1,2,3,4,5,6,7,8,9,10] numbers.insert(2,7) print(numbers)

append func

Python
2 years ago
student_1=['sai',4205,'karur'] student_2=['shakthi',4204,'karur'] student_1.append('dayscholar') student_2.append("hosteler") print(student_1) print(student_2)

pizza store

Python
2 years ago
print('Welcome to our pizza store!') bill=0 size=input("enter the size of the pizza you want[s/m/l]: \n") if size=='s' or size=='S': bill +=100 print("the small pizza costs you 100 rupees") elif size=='m' or 'M': bill +=200 print("the medium pizza costs you 200 rupees") else:

bmi

Python
2 years ago
weight=float(input("enter your weight in kg: \n")) height=float(input("enter your height in meters: \n")) bmi=weight/height**2 if (bmi<18.5): print("your bmi is",bmi,"and you are underweight") elif (bmi<25): print("your bmi is",bmi,"and you are healthy") elif (bmi<30): print("your bmi is",bmi,"and you are overweight") else:

road tax

Python
2 years ago
cost=int(input("enter the cost of the bike: \n")) if (cost<=50000): road_tax=cost*0.05 print("road tax:",road_tax) elif (cost<100000): road_tax=cost*0.1 print("road tax:",road_tax) else: road_tax=cost*0.15 print("road tax:",road_tax)

leap year

Python
2 years ago
year=int(input("enter a year: \n")) if (year%4==0): if (year%100==0): if(year%400==0): print("it is a leap year") else: print("it is not a leap year") else: print("it is a leap year") else:

work rules

Python
2 years ago
age=int(input("enter your age: \n")) sex=input("enter your sex [M or F]: \n") marital=input("enter your marital status[s or m]: \n") if (sex=="F"): print("work in urban areas") else: if(age<20): print("you cannot work") elif (age<40): print("you can work anywhere")

A student will not be allowed to sit in exam if his/her attendance is less than 75%.

Python
2 years ago
held=int(input("enter the no. of classes held: \n")) attended=int(input("enter the no. of classes attended: \n")) attendance=(attended/held)*100 print("your attendance:",attendance,"%") if (attendance>75): print("you are allowed to write the exam") else: print("you are not allowed to write the exam")

Write a program to print absolute value of a number entered by user.

Python
2 years ago
num=int(input("enter an integer: \n")) if(num<0): ans=num*-1 print(ans) else: print(num)

Take input of age of 3 people by user and determine oldest and youngest among them.

Python
2 years ago
person1=int(input("enter the age of the first person:\n ")) person2=int(input("enter the age of the second person: \n")) person3=int(input("enter the age of the third person: \n")) if (person1>person2 and person1>person3): print("the first person is the oldest") if (person2<person3): print("the second person is the youngest") else : print("the third person is the youngest") elif(person2>person1 and person2>person3):

grading

Python
2 years ago
marks=int(input("enter the marks that you obtained: \n")) if(marks>80): print("congrats! you obtained A grade") elif (marks>60): print("congrats! you obtained B grade") elif (marks>50): print("congrats! you obtained C grade") else: print("oops!you got D grade. better luck next time")

A shop will give discount of 10% if the cost is greater than 1000 rupees

Python
2 years ago
price=int(input("enter the price of the item: \n")) quantity=int(input("enter the quantity of the item: \n")) total=price*quantity if (total>1000): discount=total*0.1 final_price=total-discount print("the original price is:",total) print("the discounted price is: ",final_price) else: print("total price:",total)

Take two int values from user and print greatest among them.

Python
2 years ago
num1=int(input("enter the first integer: \n")) num2=int(input("enter the second integer: \n")) if (num1>num2): print("greatest number:",num1) elif (num2>num1): print("greatest number:",num2) else: print("both numbers are equal")