0% found this document useful (0 votes)
15 views18 pages

A.K Khan Movers

The document contains program code snippets in Python demonstrating the use of conditional statements and loops. It includes programs to check if a number is even or odd, find the maximum or minimum of three numbers, check if a year is a leap year, and print tables and sums using for and while loops. The programs take user input, apply conditional logic and loops, and display outputs.

Uploaded by

Abdul rauf Khan
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)
15 views18 pages

A.K Khan Movers

The document contains program code snippets in Python demonstrating the use of conditional statements and loops. It includes programs to check if a number is even or odd, find the maximum or minimum of three numbers, check if a year is a leap year, and print tables and sums using for and while loops. The programs take user input, apply conditional logic and loops, and display outputs.

Uploaded by

Abdul rauf Khan
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
You are on page 1/ 18

UNIVERSITY OF OKARA

NAME : RAUF KHAN MUSAKHAIL

ROLL NO : BSSE-1042

DEPATMENT : BSSE2M

SUBJECT : OOPS

TOPICS : CONDITIONAL STATENENTS & LOOPS


Write a program to print “congratulation you have
passed”
If marks of student is 40 or more than. Other wise it
display “sorry you have failed”.

marks = int(input("Enter your marks: "))

if marks >= 40:


print("Congratulations! You have passed.")
else:
print("Sorry, you have failed.")
Write a program to input two number and display
whether it is equal or not equal.

num1 = float(input("Enter the first number: "))


num2 = float(input("Enter the second number: "))

if num1 == num2:
print("The numbers are equal.")
else:
print("The numbers are not equal.")
Write a program to input three number and
display the maximum

num1 = float(input("Enter the first number: "))


num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))

max_num = max(num1, num2, num3)


print("The maximum number is:", max_num)
Write a program to input a number and
display the number is even or odd.

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

if num % 2 == 0:
print("The number is even.")
elif num % 2 == 1:
print("The number is odd.")
else:
print("Invalid input.")
Write a program to input a year and
display the year is leap year or not.

year = int(input("Enter a year: "))

if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):


print("The year is a leap year.")
else:
print("The year is not a leap year.")
Write a program to display the grade of student .

marks = float(input("Enter the marks obtained: "))

if marks >= 90:


grade = "A+"
elif marks >= 80:
grade = "A"
elif marks >= 70:
grade = "B"
elif marks >= 60:
grade = "C"
elif marks >= 50:
grade = "D"
else:
grade = "F"

print("Grade:", grade)
Write a program that return the day name.
def get_day_name(day_number):
if day_number == 1:
return "Monday"
elif day_number == 2:
return "Tuesday"
elif day_number == 3:
return "Wednesday"
elif day_number == 4:
return "Thursday"
elif day_number == 5:
return "Friday"
elif day_number == 6:
return "Saturday"
elif day_number == 7:
return "Sunday"
else:
return "Invalid day number"
day_number = int(input("Enter a number (1-7) representing a
day of the week: "))
day_name = get_day_name(day_number)
print("The corresponding day is:", day_name)
Write a program that input three number
and display the smallest number.

num1 = float(input("Enter the first number: "))


num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
smallest = num1
if num2 < smallest:
smallest = num2
if num3 < smallest:
smallest = num3
print("The smallest number is:", smallest)
Write a program that input three number a
display it is equal or not equal.

num1 = float(input("Enter the first number: "))


num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))

if num1 == num2 and num2 == num3:


print("All numbers are equal")
else:
print("Numbers are not equal")
Write to input the character and check the
given character is vowel or consonant.

char = input("Enter a character: ")

if char.lower() in 'aeiou':
print("The character is a vowel")
else:
print("The character is a consonant")
Write a program to display counting
from 1 to 10. using while loop.

count = 1

while count <= 10:


print(count)
count += 1
Write a program that display first
five number and their sum.

count = 1
sum = 0

while count <= 5:


print(count)
sum += count
count += 1

print("Sum:", sum)
Write a program that input a number
and display the table of that number.

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


count = 1

print("Multiplication Table of", num)


while count <= 10:
result = num * count
print(num, "x", count, "=", result)
count += 1
Write a program hat display back
counting from 10 t0 1.

count = 10

while count >= 1:


print(count)
count -= 1
Write a program that input starting and ending number from
user and display all odd number in the given range.

start = int(input("Enter the starting number: "))


end = int(input("Enter the ending number: "))

print("Odd numbers in the range", start, "to", end,


"are:")
current = start

while current <= end:


if current % 2 != 0:
print(current)
current += 1
Write a program that display the product
of the number from 1 to 10.

product = 1

for num in range(1, 11):


if num % 2 != 0:
product *= num

print("Product of all odd numbers from 1 to 10:",


product)
Write a program that input a number from user and
display the table of that number. Using for loop.

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

print("Multiplication Table of", num)


for count in range(1, 11):
result = num * count
print(num, "x", count, "=", result)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy