Coding Assignments (Python Basics)- Problems and Solutions
This article contains coding exercises related to python basics that includes variable definition, data types, input, print function etc.
Note: The solutions are given at the last of this article. But try to write your code before taking the help of the solutions.
Problem 1 (Variable 1)
- Store the value "The Learning Setu" in a variable called institute
- Print the contents of variable institute
Problem 2 (Variable 2)
- Create a variable called first_name and assign "Bob" into it
- Create a variable called last_name and assign "Jones" into it
- Print out the value of first_name and last_name separated by a space.
Problem 3 ( Increase an Integer by 10 )
- Take an integer value x from user
- Increase the variable x by 10
- Print the value of variable x
Example Input
15
Example Output
25
Problem 4 ( Sum of three numbers )
- Take three integers from the user (on separate lines)
- Print their sum.
2
3
6
Example output
11
Problem 5 ( Sum and Multiplication of 2 numbers )
Write a program that takes 2 numbers and prints their sum and multiplication. Every number is given on a separate line.
Example input
2
5
Example output
5
10
Problem 6 ( Greet a person )
Write a program that greets the user by printing the word "Hello", a comma, the name of the user. Take the name from the user input.
Example input
Harry
Example output
Hello, Harry
Problem 7 ( Apple Sharing )
N students take K apples and distribute them among each other evenly. The remaining (the indivisible) part remains in the basket. How many apples will each single student get? How many apples will remain in the basket?
The program reads the numbers N and K. It should print the two answers for the questions above.
Example input
6
50
Example output
8
2
Problem 8 ( Fahrenheit to Celsius )
Given a value of temperature in Fahrenheit. Convert the value into Celsius and print the integer value of the result.
Example input
97
Example output
36