0% found this document useful (0 votes)
279 views3 pages

Sample String: "Twinkle, Twinkle, Little Star, How I Wonder What You Are! Up Above The

The document provides 25 Python coding exercises ranging from basic string formatting and date/time output to more complex calculations involving math operations, lists, tuples, and built-in functions. The exercises increase in complexity and cover a variety of common Python programming tasks including accepting user input, string manipulation, working with dates, math operations, conditional logic, and more.

Uploaded by

Alaka Konda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
279 views3 pages

Sample String: "Twinkle, Twinkle, Little Star, How I Wonder What You Are! Up Above The

The document provides 25 Python coding exercises ranging from basic string formatting and date/time output to more complex calculations involving math operations, lists, tuples, and built-in functions. The exercises increase in complexity and cover a variety of common Python programming tasks including accepting user input, string manipulation, working with dates, math operations, conditional logic, and more.

Uploaded by

Alaka Konda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

1.

 Write a Python program to print the following string in a specific format (see the
output). 
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
2. Write a Python program to get the Python version you are using. 

3. Write a Python program to display the current date and time.


Sample Output :
Current date and time :
2014-07-05 14:34:14

4. Write a Python program which accepts the radius of a circle from the user and
compute the area. 
Sample Output :
r = 1.1
Area = 3.8013271108436504

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. 

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. 
Sample data : 3, 5, 7, 23
Output :
List : ['3', ' 5', ' 7', ' 23']
Tuple : ('3', ' 5', ' 7', ' 23')

7. Write a Python program to accept a filename from the user and print the extension of
that. 
Sample filename : abc.java
Output : java
8. Write a Python program to display the first and last colors from the following list. 
color_list = ["Red","Green","White" ,"Black"]

9. Write a Python program to display the examination schedule. (extract the date from
exam_st_date). 
exam_st_date = (11, 12, 2014)
Sample Output : The examination will start from : 11 / 12 / 2014

10. Write a Python program that accepts an integer (n) and computes the value of
n+nn+nnn. 
Sample value of n is 5
Expected Result : 615

11. Write a Python program to print the documents (syntax, description etc.) of Python
built-in function(s).
Sample function : abs()
Expected Result :
abs(number) -> number
Return the absolute value of the argument.

12. Write a Python program to print the calendar of a given month and year.
Note : Use 'calendar' module.

13. Write a Python program to print the following here document. 


Sample string :
a string that you "don't" have to escape
This
is a ....... multi-line
heredoc string --------> example

14. Write a Python program to calculate number of days between two dates.


Sample dates : (2014, 7, 2), (2014, 7, 11)
Expected output : 9 days

15. Write a Python program to get the volume of a sphere with radius 6.


16. Write a Python program to get the difference between a given number and 17, if the
number is greater than 17 return double the absolute difference. 

17. Write a Python program to test whether a number is within 100 of 1000 or 2000. 

18. Write a Python program to calculate the sum of three given numbers, if the values
are equal then return three times of their sum. 

19. Write a Python program to get a new string from a given string where "Is" has been
added to the front. If the given string already begins with "Is" then return the string
unchanged. 

20. Write a Python program to get a string which is n (non-negative integer) copies of a


given string. 

21. Write a Python program to find whether a given number (accept from the user) is
even or odd, print out an appropriate message to the user. 

22. Write a Python program to count the number 4 in a given list. 

23. Write a Python program to get the n (non-negative integer) copies of the first 2
characters of a given string. Return the n copies of the whole string if the length is less
than 2. 

24. Write a Python program to test whether a passed letter is a vowel or not. 

25. Write a Python program to check whether a specified value is contained in a group of


values. 
Test Data :
3 -> [1, 5, 8, 3] : True
-1 -> [1, 5, 8, 3] : False

You might also like