filmov
tv
CSE110 Lab Assignment 1 - Variables, Data types & Operators ( Python ) Bracu

Показать описание
Task 1:
Write a Python program that prints "hello world" in a console.
Task 2:
Write a Python program that prints the summation of 54 and 56. The program must use Python operators and numbers but not use any variables.
Sample Output:110
Task 3:
Write a Python program that assigns the values "Summer" and 2023 to variables season and year respectively. Then, print the values of both variables in separate lines.
Sample Output: Summer2023
Task 4: Write a Python program that reads the user's name and prints it back as shown in the examples below.
Sample Input: John
Albert
Sample Output: Your name is John
Your name is Albert
Task5: Write a Python program that reads two integers M and N respectively and finds the value of M^N (or MN) and prints the value exactly as shown in the examples below. Your code should work correctly for any other sample inputs.
Sample Input: 23 Sample
Output:2^3: 8
Task 6: A sailor has a boat known as Téssares Boat, which has four corners. The boat is capable of carrying goods of any weight as long as there is equal distribution of loads on each corner of the boat - the center area has been occupied by the engine. The sailor needs your help to know the maximum amount of weight he can carry in each shipment.
Write a Python program that reads the total weight of the shipment and prints the maximum load (or weight) the boat can take from the given shipment. We can assume that the weight of each good is exactly 1 unit, therefore, the weight of 5 units means there are 5 (loose) items in the shipment.
Sample Input:
9
11
23
Sample Output:
8
8
20
Task 7:
Write a Python program that reads 3 integers A, B, and C respectively, and then reads a floating point number D. After reading, the program should print the result (as int) using the given formula below.
Formula110: A^C+B*A-D/3
Sample Input:
2
6
8
1.3
Sample Output:
26
7
2
6
81.3
Sample Output:
267
Task 8:
Write a python program that takes an integer from the user which represents the number of chocolates that he/she has. He/She decided to distribute the chocolates equally among 3 friends, keeping the remaining chocolates for him/herself. Find out the number of chocolates each friend will receive and the number of chocolates that will be remaining.
Sample Input :
50
Sample Output :
Each friend will receive 16 chocolates
The number of remaining chocolates is 2
Write a Python program that prints "hello world" in a console.
Task 2:
Write a Python program that prints the summation of 54 and 56. The program must use Python operators and numbers but not use any variables.
Sample Output:110
Task 3:
Write a Python program that assigns the values "Summer" and 2023 to variables season and year respectively. Then, print the values of both variables in separate lines.
Sample Output: Summer2023
Task 4: Write a Python program that reads the user's name and prints it back as shown in the examples below.
Sample Input: John
Albert
Sample Output: Your name is John
Your name is Albert
Task5: Write a Python program that reads two integers M and N respectively and finds the value of M^N (or MN) and prints the value exactly as shown in the examples below. Your code should work correctly for any other sample inputs.
Sample Input: 23 Sample
Output:2^3: 8
Task 6: A sailor has a boat known as Téssares Boat, which has four corners. The boat is capable of carrying goods of any weight as long as there is equal distribution of loads on each corner of the boat - the center area has been occupied by the engine. The sailor needs your help to know the maximum amount of weight he can carry in each shipment.
Write a Python program that reads the total weight of the shipment and prints the maximum load (or weight) the boat can take from the given shipment. We can assume that the weight of each good is exactly 1 unit, therefore, the weight of 5 units means there are 5 (loose) items in the shipment.
Sample Input:
9
11
23
Sample Output:
8
8
20
Task 7:
Write a Python program that reads 3 integers A, B, and C respectively, and then reads a floating point number D. After reading, the program should print the result (as int) using the given formula below.
Formula110: A^C+B*A-D/3
Sample Input:
2
6
8
1.3
Sample Output:
26
7
2
6
81.3
Sample Output:
267
Task 8:
Write a python program that takes an integer from the user which represents the number of chocolates that he/she has. He/She decided to distribute the chocolates equally among 3 friends, keeping the remaining chocolates for him/herself. Find out the number of chocolates each friend will receive and the number of chocolates that will be remaining.
Sample Input :
50
Sample Output :
Each friend will receive 16 chocolates
The number of remaining chocolates is 2
Комментарии