Python Mastery Quest: 50 Engaging Challenges to Level Up Your Coding Skills
_image
Python Mastery Quest: 50 Engaging Challenges to Level Up Your Coding Skills

Admin

January 28, 2024

Certainly! Here are 50 basic Python practice questions grouped by 10:

😎😇

Basics:

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

2. Declare a variable `x` and assign it the value 5. Print the value of `x`.

3. Calculate the sum of two numbers (e.g., 7 and 3) and print the result.

4. Create a list with elements "apple," "banana," and "cherry." Print the list.

5. Define a function called `square` that takes a number as input and returns its square.

6. Use a loop to print the numbers from 1 to 5.

7. Check if a number is even or odd. (Print "Even" or "Odd" accordingly)

8. Create a dictionary with keys "name" and "age" and values "John" and 25. Print the dictionary.

9. Concatenate two strings and print the result.

10. Accept user input for their age and print it.

Conditionals and Loops

11. Write a program that prints numbers from 1 to 10, but skips 3 and 7.

12. Check if a given string is a palindrome.

13. Find the largest among three numbers.

14. Use a for loop to iterate through a list and print each element.

15. Write a program that prints the Fibonacci series up to 10 terms.

16. Check if a number is prime or not.

17. Create a program that prints the multiplication table of 5.

18. Use a while loop to print numbers from 1 to 5.

19. Write a program that counts the number of vowels in a given string.

20. Create a program that prints a pattern like a right-angled triangle.

Lists and Strings

21. Reverse a given string.

22. Find the average of numbers in a list.

23. Remove duplicates from a list.

24. Count the occurrences of a specific element in a list.

25. Slice a list to get the second and third elements.

26. Convert a string to uppercase.

27. Create a list of squares of numbers from 1 to 5.

28. Replace a specific element in a list with a new value.

29. Check if two strings are anagrams.

30. Sort a list of numbers in ascending order.

Functions

31. Create a function that adds two numbers and returns the result.

32. Write a function that checks if a number is positive, negative, or zero.

33. Define a function to calculate the factorial of a number.

34. Create a function that accepts a list of numbers and returns the sum.

35. Write a function that returns the middle character of a string.

36. Modify the square function to accept a default value of 2.

37. Create a function that calculates the area of a rectangle (length * width).

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

39. Create a function to find the maximum of three numbers.

40. Write a function that reverses a list.

Dictionaries and Sets

41. Add a new key-value pair to an existing dictionary.

42. Check if a key exists in a dictionary.

43. Create a dictionary comprehension to square each element in a list.

44. Remove an element from a set.

45. Merge two dictionaries.

46. Check if two sets have any elements in common.

47. Write a program to count the frequency of each word in a sentence.

48. Create a set of common elements between two sets.

49. Combine two lists into a dictionary.

50. Write a program to find the second-largest element in a list.

These questions cover a range of basic Python concepts and should help you practice and reinforce your understanding of the language.