0% found this document useful (0 votes)
433 views

Python Practical Questions For HND Pearson

The document contains 50 Python practical questions for an HND Pearson exam. It provides instructions for students to write individual Python files for each question, save them in a folder named with their index number, and submit it before 4pm. The questions cover a range of Python programming topics including string formatting, date/time, math operations, lists, tuples, files, modules and more. Students are expected to write Python code to solve each problem and return the expected output.

Uploaded by

fudhailfaizal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
433 views

Python Practical Questions For HND Pearson

The document contains 50 Python practical questions for an HND Pearson exam. It provides instructions for students to write individual Python files for each question, save them in a folder named with their index number, and submit it before 4pm. The questions cover a range of Python programming topics including string formatting, date/time, math operations, lists, tuples, files, modules and more. Students are expected to write Python code to solve each problem and return the expected output.

Uploaded by

fudhailfaizal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

Python Practical questions for HND Pearson

Duration : 3 hours

Note : Create separate python files for each question and add them to a one folder with
naming the folder with your index number and send it to tharaka.m@esoft.lk before 4.00pm.

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

26. Write a Python program to create a histogram from a given list of integers. 

27. Write a Python program to concatenate all elements in a list into a string


and return it. 

28. Write a Python program to print all even numbers from a given numbers
list in the same order and stop the printing if any numbers that come after 237
in the sequence. 
Sample numbers list :
numbers = [
386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978,
328, 615, 953, 345,
399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866,
950, 626, 949, 687, 217,
815, 67, 104, 58, 512, 24, 892, 894, 767, 553, 81, 379,
843, 831, 445, 742, 717,
958,743, 527
]
29. Write a Python program to print out a set containing all the colors from
color_list_1 which are not present in color_list_2. 
Test Data :
color_list_1 = set(["White", "Black", "Red"])
color_list_2 = set(["Red", "Green"])
Expected Output :
{'Black', 'White'}

30. Write a Python program that will accept the base and height of a triangle
and compute the area. 

31. Write a Python program to compute the greatest common divisor (GCD) of


two positive integers. 

32. Write a Python program to get the least common multiple (LCM) of two
positive integers. 

33. Write a Python program to sum of three given integers. However, if two


values are equal sum will be zero. 

34. Write a Python program to sum of two given integers. However, if the sum
is between 15 to 20 it will return 20. 

35. Write a Python program that will return true if the two given integer values
are equal or their sum or difference is 5. 

36. Write a Python program to add two objects if both objects are an integer
type. 

37. Write a Python program to display your details like name, age, address in
three different lines. 
38. Write a Python program to solve (x + y) * (x + y). 
Test Data : x = 4, y = 3
Expected Output : (4 + 3) ^ 2) = 49

39. Write a Python program to compute the future value of a specified


principal amount, rate of interest, and a number of years. 
Test Data : amt = 10000, int = 3.5, years = 7
Expected Output : 12722.79

40. Write a Python program to compute the distance between the points (x1,
y1) and (x2, y2). 

41. Write a Python program to check whether a file exists. 

42. Write a Python program to determine if a Python shell is executing in 32bit


or 64bit mode on OS. 

43. Write a Python program to get OS name, platform and release


information. 

44. Write a Python program to locate Python site-packages. 

45. Write a python program to call an external command in Python. 

46. Write a python program to get the path and name of the file that is
currently executing. 

47. Write a Python program to find out the number of CPUs using. 

48. Write a Python program to parse a string to Float or Integer. 


49. Write a Python program to list all files in a directory in Python. 

50. Write a Python program to print without newline or space. 

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy