Ict Python Programs
Ict Python Programs
if a > b:
print(a, "is the greater number")
elif b > a:
print(b, "is the greater number")
else:
print("Both your numbers are equal")
if a >= 40:
print("Congrats, you passed")
else:
print("Sorry, you failed")
if a >= 90:
print("Your Grade is an A*!")
elif a >= 80:
print("Your Grade is an A")
elif a >= 70:
print("Your Grade is a B")
elif a >= 60:
print("Your Grade is a C")
elif a >= 50:
print("Your Grade is a D")
elif a >= 40:
print("Your Grade is an E")
else:
print("Your Grade is a U")
# 📌 Temperature Classification
# Program: Temperature Classification
i=1
while i < 11:
print(i)
i += 1
sum = 0
i = int(input("Enter a number. Enter 0 to stop: "))
while i != 0:
sum += i
print("Current sum:", sum)
i = int(input("Enter a number: "))
# 📌 Multiplication Table
# Program: Multiplication Table of a Number
secret = 20
guess = int(input("Enter your guessed number: "))
# 📌 Jump Statements
# Jump Statement - break
avg = total / n
print("Average Temperature is", avg, "°")
for i in range(10):
if n == 7:
continue
else:
print(n)
ICT HW PROGRAMS
Program 1
a = int(input("Enter your marks: "))
if a >= 90:
print("Your Grade is an A!")
elif a >= 80:
print("Your Grade is an B")
elif a >= 70:
print("Your Grade is a C")
elif a >= 60:
print("Your Grade is a D")
else:
print("Your Grade is an F")
Program 2
temp = int(input("Enter the temperature in degrees: "))
if temp > 30:
print("It's too hot! Stay indoors.")
elif temp >= 20:
print("It's a nice day")
elif temp < 20:
print("It's cold! Wear a jacket.")
Program 4
n = int(input("Enter the number up to which you want the sum: "))
sum = 0
for i in range(1, n + 1):
sum = sum + i
print("The sum of", n, "natural numbers is", sum)
Program 5
for i in range(10, 0, -1):
print(i)
print("Time's up!")
Program 6
n = int(input("Enter the number you want in the table: "))
for i in range(1, 11):
print(n, "*", i, "=", n * i)
Program 7
n = 13
an = int(input("Guess the secret number (between 1 and 20): "))
while an != n:
if an < 1 or an > 20:
print("Please enter a number between 1 and 20.")
elif an < n:
print("Too low! Try again.")
elif an > n:
print("Too high! Try again.")
an = int(input("Enter guess again: "))
print("Congratulations! You guessed it!")
Program 8
an = 3243
n = int(input("Enter your guessed number: "))
while an != n:
print("Pin is incorrect! Please try again")
n = int(input("Enter new attempt: "))
print("Access Granted")
Program 9
an = 3243
n = int(input("Enter your guessed number: "))
while an != n:
print("Pin is incorrect! Please try again.")
if n < an:
print("Too low! Try again.")
else:
print("Too high! Try again.")
n = int(input("Enter new attempt: "))
print("Congratulations! Your Pin is correct.")
Program 10
cp = "PythonRocks"
a = 0
ma = 3
while a < ma:
p = input("Enter your password: ")
if p == cp:
print("Access Granted!")
break
else:
a += 1
print("Incorrect password. Please try again.")
if a == ma:
print("Account Locked!")
Program 11
for i in range(2, 21, 2):
print(i)
Program 12
num = 0
while num >= 0:
try:
num = float(input("Enter a number (negative to stop): "))
if num < 0:
print("Negative number detected. Exiting!")
except ValueError:
print("Invalid input. Please enter a valid number.")
Program 13
while 1:
user_input = input("Enter a number: ")
if user_input == 'exit':
print("Exiting the program.")
break
number = int(user_input)
if number % 7 == 0:
print("First multiple of 7 found:", number)
break
Program 14
name = input("Please enter your name:\n")
age = int(input("What is your age?\n"))
tv_show = input("What is your favourite TV programme?\n")
print(f"{name} is {age} years old and likes {tv_show}")
Program 15
print("Rectangle 1")
length1 = int(input("Please enter the length:\n"))
width1 = int(input("Please enter the width:\n"))
area1 = length1 * width1
print("\nRectangle 2")
length2 = int(input("Please enter the length:\n"))
width2 = int(input("Please enter the width:\n"))
area2 = length2 * width2
if area1 > area2:
print("\nRectangle 1 has the largest area")
elif area2 > area1:
print("\nRectangle 2 has the largest area")
else:
print("\nBoth rectangles have the same area")