Python Basic (Part -I) -
Exercises, Practice, Solution
Last update on June 27 2020 08:54:40 (UTC/GMT +8 hours)
Python basic (Part -I) [150 exercises with
solution]
[An editor is available at the bottom of the page to write and
execute the scripts.]
1. Write a Python program to print the following string in a
specific format (see the output). Go to the editor
Sample String : "Twinkle, twinkle, little star, How I wonder
what you are! Up above the world so high, Like a diamond in
the sky. Twinkle, twinkle, little star, How I wonder what you
are" Output :
Twinkle, twinkle, little star,
How I wonder what you are!
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are
Click me to see the sample solution
2. Write a Python program to get the Python version you are
using. Go to the editor
Click me to see the sample solution
3. Write a Python program to display the current date and
time.
Sample Output :
Current date and time :
2014-07-05 14:34:14
Click me to see the sample solution
4. Write a Python program which accepts the radius of a circle
from the user and compute the area. Go to the editor
Sample Output :
r = 1.1
Area = 3.8013271108436504
Click me to see the sample solution
5. Write a Python program which accepts the user's first and
last name and print them in reverse order with a space
between them. Go to the editor
Click me to see the sample solution
6. Write a Python program which accepts a sequence of
comma-separated numbers from user and generate a list and
a tuple with those numbers. Go to the editor
Sample data : 3, 5, 7, 23
Output :
List : ['3', ' 5', ' 7', ' 23']
Tuple : ('3', ' 5', ' 7', ' 23')
Click me to see the sample solution