Lab 01 Homework Summer 2024 (1)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Department of Computer Science and Engineering

CSE101: Introduction to Computer Science

Assignment - Lab 02 | Semester: Summer 2024

Homework

1. Write a Python program that takes two inputs from the user, his/her name and his/her
department. In output, print as follows.

Sample Input:
Please enter your Name: Tom
Please enter your department: architecture

Sample Output:
Hey Tom! You must be from the architecture department.

2. Write a Python program that read three integers from the user, and prints their sum and
average value:

Sample Input:
First number: 15
Second number: 20
Third number: 10

Sample Output:
Sum: 45
Average: 15.0
3. Write a Python program that prompts the user for their name, street address, city, and zip
code. and prints the name and Address in the following order.

Sample Input:
Name: John
Street address: xyz road
City: Dhaka
Zip code: 1212

Sample Output:
Hi! I am John,
I live in xyz road,Dhaka-1212

4. Write a Python program that reads a temperature in Celsius from the user and converts it
to Fahrenheit. And print the temperature in Fahrenheit.
[Hint: Fahrenheit=((9/5)​×Celsius)+32]

Sample Input:
Temperature in Celsius: 25.0

Sample Output:
Temperature in Fahrenheit: 77.0
5. Write a Python program that reads the lengths of the perpendicular (a) and the base (b) of
a left-angled triangle from the user and calculates the length of the hypotenuse (c) using
the Pythagorean theorem and print the length of the hypotenuse.
[HINT: c² =a²+b²;
c= hypotenuse;
a= perpendicular;
b=base]

Sample Input:
Perpendicular: 3
Base:4

Sample Output:
Hypotenuse: 5.0
FlowChart

1. Draw a flowchart of a program, which will take a number from the user and print if
the number is a positive number or a negative number. For example, if the user gives
5, then print “It is a positive number”. If the user gives -10, then print “It is not a
positive number”.

2. Draw a flowchart of a program, which will take a number N from the user and print all
the odd numbers till N. For example, if the user gives 10, then print all the odd
numbers that are less than 10. (1,3,5,7,9).

3. Draw a flowchart of a program which will take three inputs and solve the equation as
an output. The equation is "(X^2+Y^3+Z^4)/X^5"

4. Draw a flowchart of a program, which will take a number N from the user and print
the sum of the numbers from 1 to N-1. For example, if the user's input is 10, then the
output is going to be 45. (1+2+3+4+5+6+7+8+9 = 45)

5. Draw a flowchart of a program which will take an input from 1 to 20 and print whether
it is a prime number or not which is divisible by 3.

You might also like