Assignment_1
Assignment_1
Assignment 1
Deadline: 04:00PM, Monday 18 Nov 2024
Important Instructions
• The assignment should be hand-written on plane A4 size Paper only. Section A will submit Odd
Questions and Section B will submit even questions. However, you will do all the questions on
VS Code in single .py file that can be collected online.
• Before writing the questions on paper, first do it on VS Code and ensure that it generates the
right output.
• Before getting help from online resources/colleagues, try to develop the code yourself, it will
prepare you for upcoming exams well.
• Write the following at the top of the first page:
Assignment-1
Name: __________
Reg. No.: ________
Section: __________
1
Write a Python program that takes the user’s name and age as input, then displays a message
saying, “Hello [name], you are [age] years old!”
2
An aircraft travels at a constant speed. Write a program that takes speed (in km/h) and time
(in hours) as input and calculates the distance traveled. (Distance = Speed * Time)
3
Write a program to calculate the area and perimeter of a rectangle. The program should take
length and width as input and then display the area and perimeter.
4
Write a Python program that determines whether a given number (accepted from the user) is
even or odd and prints an appropriate message to the user.
5
Write a program that takes three numbers as input from the user and prints the largest one
using conditional statements.
6
Write a program that calculates the total fuel consumption of an aircraft based on fuel flow
rate and flight duration.
Page 1 of 5
Introduction to Information Technology [108443] Session: 2024 (AVE-10)
7
Write a program to check if a given number is a prime number.
8
Write a program to display the multiplication table of a given number (from 1 to 10).
9
Write a Python program that finds and prints all the prime numbers between 1 and 100.
10
Write a Python program that calculates the sum of all numbers from 1 to a given number
entered by the user.
11
Write a Python program that prints all numbers between 1 and 50 that are divisible by both 3
and 5.
12
Write a Python program to guess a number between 1 and 9.
Note: User is prompted to enter a guess. If the user guesses wrong then the prompt appears
again until the guess is correct, on successful guess, user will get a "Well guessed!" message,
and the program will exit.
To generate a random number between 1 and 9, import random module and use randint()
function.
13
Write a Python program to get the Fibonacci series between 0 and 50.
Note: The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, ....
Every next number is found by adding up the two numbers before it.
Expected Output: 1 1 2 3 5 8 13 21 34
14
Write a program that can find the factorial of any given number. For example, find the factorial
of the number 5 (often written as 5!) which is 1 * 2 * 3 * 4 *5 and equals 120.
The factorial is not defined for negative numbers, and the factorial of zero is 1; that is 0! = 1.
Your program should take as input an integer from the user.
Do this question using while loop.
Page 2 of 5
Introduction to Information Technology [108443] Session: 2024 (AVE-10)
15
Repeat the above question using for loop.
16
Write a program to count the number of vowels in a given string.
17
Write a program to count the number of consonants in a given string.
18
Write a program to check if a string is a palindrome.
Write a python code using nested loops to print the following patterns:
19
20
21
Page 3 of 5
Introduction to Information Technology [108443] Session: 2024 (AVE-10)
22
23
24
25
Page 4 of 5
Introduction to Information Technology [108443] Session: 2024 (AVE-10)
26
Write a program to print twin primes less than 1000. If two consecutive odd numbers are both
prime, then they are known as twin primes. E.g., 3 and 5.
Page 5 of 5