[Go to site: main page, start]

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

Assignment Python

The document contains several Python programs demonstrating basic programming concepts. It includes a grading system based on marks, a Fibonacci series generator, a prime number checker, a leap year validator, and functions to identify odd/even numbers and count vowels/consonants in a word. Each program prompts user input and displays the results accordingly.

Uploaded by

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

Assignment Python

The document contains several Python programs demonstrating basic programming concepts. It includes a grading system based on marks, a Fibonacci series generator, a prime number checker, a leap year validator, and functions to identify odd/even numbers and count vowels/consonants in a word. Each program prompts user input and displays the results accordingly.

Uploaded by

chistyybhai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

01.

Sonargaon University Grading System (0-100 marks)


marks = float(input("Enter marks (0-100): "))

if 0 <= marks <= 100:

if marks >= 80:

grade = "A+"

elif marks >= 75:

grade = "A"

elif marks >= 70:

grade = "A-"

elif marks >= 65:

grade = "B+"

elif marks >= 60:

grade = "B"

elif marks >= 55:

grade = "B-"

elif marks >= 50:

grade = "C+"

elif marks >= 45:

grade = "C"

elif marks >= 40:

grade = "D"

else:

grade = "F"

print(f"Marks: {marks}, Grade: {grade}")

else:

print("Invalid input! Please enter marks between 0 and 100.")


02. Fibonacci series using while loop

i=1

a=0

b=1

sum = 1

n = int(input("Enter the range "))

while i<=n:

print(sum, end=" ")

sum = a + b

a=b

b = sum

i = i+1
03. Python program to check if a number is prime or composite

num = int(input("Enter a number: "))

if num > 1:

for i in range(2, num):

if num % i == 0:

print("composite number")

break

else:

print("prime number")

else:

(print("neither composite number or prime"))


[Link] find if a year is leap year or not

Y = int(input("Enter the year: "))

if Y % 4 == 0 and Y % 100 != 0:

print(f"Year {Y} is a leap year")

else:

if Y % 400 == 0:

print(f"Year {Y} is a leap year")

else:

print(f"Year {Y} is not a leap year")


[Link] find number of odd and even number list

#Odd number identify

n = int(input("Enter the range: "))

for i in range(1,n+1,2):

print(i, end=",")

#even number identify

n = int(input("Enter the range: "))

for i in range(2,n+1,2):

print(i, end=",")
[Link] find the number of vowels and consonants in a word using function.

word = input("Enter the range: ")

vowel = "aeioUAEIOU"

vowel_count = 0

consonant_count = 0

for i in word:

if [Link]():

if i in vowel:

vowel_count += 1

else:

consonant_count += 1

print(f'word = {word} \nvowel ={vowel_count} \n consonant = {consonant_count}')

You might also like