0% found this document useful (0 votes)
17 views7 pages

ICT Complete Assignment

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)
17 views7 pages

ICT Complete Assignment

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
You are on page 1/ 7

Application of ICT

ASSIGNMENT NO 1
NAME : NOSHAIRWAN HAIDER
CMS ID : 507575
CLASS : EE 16 -A

1. Write a Python program that prints the numbers from 1 to 50, but:
 For multiples of 3, print "Fizz" instead of the number.
 For multiples of 5, print "Buzz" instead of the number.
 For multiples of both 3 and 5, print "FizzBuzz".
SOL :
for a in range(1, 51):

if a % 3 == 0:
print("Fizz")
elif a % 5 == 0:
print("Buzz")
elif a % 3 == 0 and a % 5 == 0:
print("FizzBuzz")
else:
print(a)

2) Ask the user to input a number. Write a Python program to check if the number is a prime number
or not.

 The program should use a loop to check divisibility and condition statements to
determine primality.

Solution :

user_input = input("Enter a number: ")

try:
number = int(user_input)
is_prime = True
if number < 2:
is_prime = False
else:
for i in range(2, number):
if number % i == 0:
is_prime = False
break

if is_prime:
print(number, "is a prime number.")
else:
print(number, "is not a prime number.")

except ValueError:
print("Please enter a valid number.”)

3) write a Python program that takes an input n and prints the following pattern:
1

12

123

1234

...

 The program should continue this until it prints n rows.

SOL :
n = int(input("Enter the number of rows: "))
for i in range(1, n + 1):

for j in range(1, i + 1):


print(j, end=" ")
print()

4) Set a secret number in your code (e.g., secret_number = 7). Write a program that asks
the user to guess the number and provides feedback:
 If the guess is too low, print "Too low, try again!"
 If the guess is too high, print "Too high, try again!"
 The loop should continue until the user guesses the correct number.

SOL:

secret_number = 67

while True:

guess = int(input("Guess the secret number: "))

if guess < secret_number:


print("Too low, try again!")
elif guess > secret_number:
print("Too high, try again!")
else:
print("Congratulations! You've guessed the number!")
break

5) Ask the user to input a string. Write a program that counts how many vowels (a, e, i, o,
u) are in the string.

SOL :
user_string = input("Enter a string: ")

vowel_count = 0

vowels = "aeiou"
for char in user_string:

if char in vowels:
vowel_count = vowel_count + 1

print("Total number of vowels:", vowel_count)

NOTE :
This assignment is been submitted late as I was suffering from
“dengue” due to which I was on complete bed rest. It is
requested to accept my late submission taking consideration of
my dieseas . Test and docter prescription are attached bellow

You might also like