The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by ushasreeapsstcblr2021, 2024-06-14 00:25:12

class 10 practical

10th practical

Aim: Write a program to check whether a person is eligible to vote or not. Objective: To check whether a person is eligible or not using if else condition Code: age=int(input(“ Enter a person AGE :”)) if age>=18: print("Person is Eligible for voting ") else: print("Person is not Eligible for voting") Aim: Print 5 lines about yourself using print() function Objective: To print about yourself using print() function Code: name=input("Enter your Name:") std=input("Enter your Class:") father=input("Enter your Father Name:") mother=input("Enter your Mother Name:") hobby=input("Enter your Hobbies:") print("1. My name is: ",name) print("2. I am studying in class: ",std) print("3. My father's name is: ",father) print("4. My mother's name is: ",mother) print("5. My hobbies are: ",hobby) Aim: Write a python program to calculate Simple Interest Objective: To find simple interest using oppropriate operators Code: p = float(input("Enter the principle amount : ")) r = float(input("Enter the rate of interest : ")) t = float(input("Enter the time in the years: ")) si = (p*r*t)/100 print("Principle amount: ", p) print("Interest rate : ", r) print("Time in years : ", t) print("Simple Interest : ", si) Aim: Write a program in python to calculate the percentage of a student who secured marks in 5 subjects out of 100 in each. Objective: To calculate percentage of marks in 5 subjects using oppropriate operators Code: name=input("Enter your name: ") m1=int(input("Enter your marks in English= ")) m2=int(input("Enter your marks in Hindi= ")) m3=int(input("Enter your marks in Maths= ")) m4=int(input("Enter your marks in Science= ")) m5=int(input("Enter your marks in Social= ")) p=((m1+m2+m3+m4+m5)/500)*100 print ("My Name is", name,"and my percentage is", p) Aim: Write a python program to find whether the number entered by the user is even or odd. Objective: To check whether the given number is even or odd using if else condition Code: n=int(input("Enter your Number=")) if n%2==0: print("Entered number is Even",n) else: print("Entered number is Odd",n) Aim: Write a python program to swap values of two variables Objective: To swap values using temporary variable Code: var1=input("Enter the first variable: ") var2=input("Enter the second variabl: ") temp = var1 var1 = var2 var2 = temp print("The value of the 1st variable after swapping is:",var1) print("The value of the 2st variable after swapping is:",var2)


Aim: Write a program to make a simple calculator Objective: To make a simple calculator using user defined functions and while loop Code: def add(x, y): return x + y def subtract(x, y): return x – y def multiply(x, y): return x * y def divide(x, y): return x / y print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") while True: choice = input("Enter your choice(1/2/3/4): ") if choice in ('1', '2', '3', '4'): num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) if choice == '1': print(num1, "+", num2, "=", add(num1, num2)) elif choice == '2': print(num1, "-", num2, "=", subtract(num1, num2)) elif choice == '3': print(num1, "*", num2, "=", multiply(num1,num2)) elif choice == '4': print(num1, "/", num2, "=", divide(num1, num2)) next_calculation = input("Let's do next calculation? (yes/no): ") if next_calculation == "no": Break else: print("Invalid Input") Aim: Write a program to check whether a year is a leap year or not Objective: To check whether the entered year is leap year or not using if else condition Code: year = int(input('Enter year: ')) if (year%400= =0) or (year%4= =0 and year%100!=0): print('LEAP YEAR') else: print('NOT LEAP YEAR') Aim: Write a program in python to count lower, upper, numeric and special characters in string Objective: To count different types of characters in entered string using for loop Code: n = '@pyThOnl56obb!Y34' numeric = 0 lower = 0 upper = 0 special = 0 for i in range(len(n)): if n[i].isnumeric(): numeric = numeric + 1 elif n[i].islower(): lower = lower+1 elif n[i].isupper(): upper = upper+1 else: special = special + 1 print("Numeric counts",numeric) print("Lower counts",lower) print("Upper counts",upper) print("Special counts",special)


Click to View FlipBook Version