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

Python file

The document contains various Python code snippets for different practical exercises, including calculating the sum of odd numbers, finding the largest and smallest of three numbers, generating patterns, converting distances from meters to centimeters, and checking age eligibility for voting. Each code snippet prompts the user for input and performs specific operations based on that input. The document serves as a collection of basic programming tasks and examples.

Uploaded by

Avinash
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python file

The document contains various Python code snippets for different practical exercises, including calculating the sum of odd numbers, finding the largest and smallest of three numbers, generating patterns, converting distances from meters to centimeters, and checking age eligibility for voting. Each code snippet prompts the user for input and performs specific operations based on that input. The document serves as a collection of basic programming tasks and examples.

Uploaded by

Avinash
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

odd sum

n = int(input("Enter the value of n:"))


odd_sum=0
if n%2==0:
for i in range(1,n,2):
odd_sum+=i
else:
for i in range(1,n+1,2):
odd_sum+=i
print("sum is",odd_sum)
large and small testing in 3 number practical 3

a=int(input("Enter first number"))


b=int(input("Enter second number"))
c=int(input("Enter third number"))

if (a>b and a>c):


print("the largest number is", a)

elif (b>a and b>c):


print("the largest number is", b)

else:
print("the largest number is", c)
larger and smaller number testing practical 2

a=int(input("Enter first number"))


b=int(input("Enter second number"))

if a>=b:
print("first is greater number")
print("second is smaller number")

else:
print("second number is greater")
print("first number is smaller")
pattern generate 2

n=int(input("write a number for pattern"))


for i in range (n,0,-1):
for j in range (0,i):
print("*",end="")
print(" ")
pattern generate 3

ch=65
n=int(input("Number of rows"))
for i in range(0,n):
ch = 65
for j in range(0,i+1):
print(chr(ch),end="")
ch=ch+1
print(" ")
distance from meter to cm

dist_mtr = float(input("Enter distance in meter"))


dist_cmtr = dist_mtr*100
print(dist_cmtr)
pattern generate 1

n=int(input("write a number for pattern"))


for i in range(0,n):
for j in range(0,i+1):
print("*",end="")
print(" ")
welcome practical 1

a=input("welcome to this program")


print('a')
age checking for vote

print("This software is created for checking age for vote")

age = int(input("Enter your age"))

if age<18:
print("you are a minor")
else:
print("you are eligible to vote")

You might also like