0% found this document useful (0 votes)
4 views5 pages

Python Beginner Programming Exercises

Uploaded by

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

Python Beginner Programming Exercises

Uploaded by

localhost
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Beginner-Level Questions

1. Print 'Hello, World!' in Python.


Example: The program should display 'Hello, World!' on the screen.

2. Create a variable called `name` and assign your name to it.


Example: Store your name in a variable and print it.

3. Swap two numbers without using a third variable.


Example: If `a = 5` and `b = 10`, swap them so `a` becomes 10 and `b` becomes 5.

4. Write a program to check if a number is even or odd.


Example: If the input is `7`, the output should be 'Odd'.

5. Find the largest among three numbers.


Example: Given three numbers 12, 25, and 9, find the largest.

6. Reverse a string using slicing.


Example: If the input is 'Python', the output should be 'nohtyP'.

7. Convert temperature from Celsius to Fahrenheit.


Example: Convert `0°C` to Fahrenheit using the formula `F = (C × 9/5) + 32`.

8. Write a program to calculate the factorial of a number.


Example: If the input is `5`, the output should be `5! = 120`.

9. Find the sum of all numbers in a list.


Example: Given `[1, 2, 3, 4]`, the output should be `10`.

10. Find the maximum and minimum values in a list.


Example: For `[3, 7, 2, 9]`, find the max (`9`) and min (`2`).

11. Check if a given number is positive, negative, or zero.

12. Write a Python program to swap two strings.

13. Convert a given string to uppercase.

14. Find the square and cube of a number.

15. Print all odd numbers between 1 and 20.

16. Find the sum of even numbers between 1 and 100.

17. Check if a given year is a leap year.

18. Write a Python function to check if a number is prime.


19. Generate a random number between 1 and 100.

20. Find the sum of digits in a given number.

21. Reverse a given number.

22. Merge two lists into one.

23. Remove duplicates from a list.

24. Write a function to check if a list is sorted.

25. Convert a list of characters into a string.

26. Find the index of a specific element in a list.

27. Find the second largest element in a list.

28. Convert kilometers to miles.

29. Convert hours into minutes and seconds.

30. Find the remainder of a division operation without using `%`.

31. Print the first 10 Fibonacci numbers.

32. Find the sum of all elements in a tuple.

33. Write a function to check if a string contains only digits.

34. Convert a string to a list of words.

35. Sort a list in ascending and descending order.

36. Find the intersection of two lists.

37. Write a function to count occurrences of a character in a string.

38. Write a program to print the multiplication table of a number.

39. Write a function to check if a given string starts with 'A'.

40. Find the common elements between two lists.

41. Convert a dictionary to a list of tuples.

42. Write a function to check if a string ends with '.com'.

43. Remove all vowels from a given string.

44. Replace spaces in a string with hyphens.

45. Count the number of words in a sentence.


46. Extract all numbers from a given string.

47. Find the largest digit in a given number.

48. Convert lowercase letters to uppercase in a string.

49. Find the sum of the first N natural numbers.

50. Write a function to generate a list of even numbers from 1 to N.

51. Create a function to check if a string is a valid email address.

52. Extract the domain name from an email address.

53. Find the average of numbers in a list.

54. Create a program that generates a random password.

55. Count the frequency of elements in a list.

56. Find the largest word in a given sentence.

57. Write a function to check if a number is a perfect square.

58. Print numbers from 1 to 10 using a while loop.

59. Write a function to check if a given string contains special characters.

60. Create a function to return the reverse of a number.

61. Check if a given number is a palindrome.

62. Convert a list into a set.

63. Remove all occurrences of a given value from a list.

64. Find the common letters in two given strings.

65. Find the missing number in a sequence of numbers.

66. Write a function to count the occurrences of a word in a text.

67. Convert a decimal number to binary.

68. Convert a binary number to decimal.

69. Write a function to check if a given year is a leap year.

70. Find the factors of a given number.

71. Convert inches to centimeters.

72. Convert a list of numbers into their string representation.


73. Find the difference between two lists.

74. Create a function that removes spaces from a string.

75. Convert a string to title case.

76. Write a program to print the ASCII value of a character.

77. Calculate the sum of numbers in a set.

78. Write a program to calculate simple interest.

79. Convert seconds into hours, minutes, and seconds.

80. Find the smallest number in a list.

81. Convert a list of numbers into a dictionary with square values.

82. Write a function to calculate the power of a number.

83. Find the sum of squares of the first N natural numbers.

84. Count the number of uppercase and lowercase letters in a string.

85. Find the last digit of a given number.

86. Check if a number is divisible by another number.

87. Calculate the sum of prime numbers in a range.

88. Convert a given number of days into weeks and days.

89. Write a program to replace all occurrences of a given character in a string.

90. Write a function to check if two strings are anagrams.

91. Convert a tuple into a dictionary.

92. Find the cube root of a number.

93. Write a function to check if a number is an Armstrong number.

94. Write a program to find the LCM of two numbers.

95. Write a function to find the GCD of two numbers.

96. Create a program that finds the area of a triangle.

97. Find the sum of elements at even indices in a list.

98. Write a function to check if a given string is a pangram.

99. Write a function to reverse the words in a sentence.


100. Create a Python program that counts the number of digits in a number.

You might also like