0% found this document useful (0 votes)
3 views11 pages

Computer Practical File

The document is a practical file for computer programming exercises for the academic year 2025-2026, authored by Shaurya Srivastava. It includes various programming tasks such as printing messages, calculating areas, checking odd/even numbers, determining leap years, and generating Fibonacci series. Each task is accompanied by code snippets and expected outputs.

Uploaded by

shauryagamefreak
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)
3 views11 pages

Computer Practical File

The document is a practical file for computer programming exercises for the academic year 2025-2026, authored by Shaurya Srivastava. It includes various programming tasks such as printing messages, calculating areas, checking odd/even numbers, determining leap years, and generating Fibonacci series. Each task is accompanied by code snippets and expected outputs.

Uploaded by

shauryagamefreak
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

COMPUTER PRACTICAL

FILE

2025-2026

SHAURYA SRIVASTAVA
ROLL No. 20
INDEX
(1) Write a program to print hello . message
Code:
print("welcome")
output:

(2) Write a program to find the area . and


circumference of a circle
Code:
a=int(input("enter a number"))#input=7
b=(2*22*a)/7
c=(22*a*a)/7
print("area",c)
print("circumference",b)
output:

(3) input three numbers and display . the


largest and smallest number
Code:
a = int(input("Enter first number: "))
b = int(input("Enter second number:"))
c = int(input("Enter third number: "))
print("Largest:", max(a, b, c))
print("Smallest:", min(a, b, c))
output:
(4) write a program to check entered . number is odd or even
Code:
a=int(input("enter a number"))
if a%2==0 :
print("even")
else :
print("odd")

Output:

(5) write a program to check entered . Year is leap year or


not
Code:
Year = int(input(“Enter a year: “))
If year % 4 == 0:
Print(“Leap year”)
Else:
Print(“Not a leap year”)

Output:
(6) Write a program to check entered character is vowels, consonants, uppercase, lowercase,special
characters.

Code:

Ch = input(“Enter a character: “)

If ch in “AEIOU”:

Print(“Uppercase Vowel”)

elif ch in “aeiou”:

Print(“Lowercase Vowel”)

elif [Link]():

Print(“Uppercase Consonant”)

elif [Link]():

Print(“Lowercase Consonant”)

else:

Print(“Special Character”)

Output:
(8)Telephone company
Code:
calls = int(input("Enter number of calls: "))
bill = 0
if calls <= 50:
bill = 0
elif calls <= 150:
bill = (calls - 50) * 2
elif calls <= 350:
bill = (100 * 2) + (calls - 150) * 1.50
else:
bill = (100 * 2) + (200 * 1.50) + (calls - 350) * 1

print("Total telephone bill: Rs.", bill)


Output:

(9)Write a program to input the value of and n and print the sum of
the following series:
Code:
1)x = int(input(“Enter x: “))
N = int(input(“Enter n: “))
S = 1
For I in range(1, n+1):
S = s + x**i
Print(“Sum =”, s)
2)x = int(input(“Enter x: “))
N = int(input(“Enter n: “))
S = 1
Sign = -1
For I in range(1, n+1):
S = s + sign * (x**i)
Sign = -sign
Print(“Sum =”, s)
3)x = int(input(“Enter x: “))
N = int(input(“Enter n: “))
S = 0
For I in range(1, n+1):
S = s + (x**i)/i
Print(“Sum =”, s)

4)x = int(input(“Enter x: “))


N = int(input(“Enter n: “))
S = 0
Fact = 1
For I in range(1, n+1):
Fact = fact * i
S = s + (x**i)/fact
Print(“Sum =”, s)
Output:
1) 2)

3) 4)

(10)Check input for number or alphabet, if it is alphabet check for


vowel or consonant.
Code:
Ch = input(“Enter a character: “)
If [Link]():
Print(“It is a number”)
Elif [Link]():
If ch in “AEIOUaeiou”:
Print(“It is a vowel”)
Else:
Print(“It is a consonant”)
Else:
Print(“It is a special character”)
Output:

(11)Factorial of a number:
Code:
N = int(input(“Enter a number: “))
Fact = 1
For I in range(1, n + 1):
Fact = fact * i
Print(“Factorial =”, fact)
Output”

(12)Fibonacci series upto n numbers :


Code:
N = int(input(“Enter n: “))
A = 0
B = 1
For I in range(n):
Print(a)
C = a + b # addition
A = b
B = c
Output:

You might also like