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

Python Class Activities

The document provides a comprehensive list of basic Python programming tasks and exercises, covering topics such as printing, arithmetic operations, string manipulation, lists, conditionals, loops, functions, dictionaries, sets, file handling, and general programming concepts. Each task includes specific programming challenges to enhance understanding and skills in Python. It serves as a practical guide for beginners to learn and practice Python programming.

Uploaded by

Yonas Teshale
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 views3 pages

Python Class Activities

The document provides a comprehensive list of basic Python programming tasks and exercises, covering topics such as printing, arithmetic operations, string manipulation, lists, conditionals, loops, functions, dictionaries, sets, file handling, and general programming concepts. Each task includes specific programming challenges to enhance understanding and skills in Python. It serves as a practical guide for beginners to learn and practice Python programming.

Uploaded by

Yonas Teshale
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

Basics

1. How do you print "Hello, World!" in Python?

2. Write a program to add two numbers.

3. Write a program to find the square of a number.

4. How do you swap two variables?

5. Write a program to find the largest of two numbers.

6. How do you take user input in Python?

7. Write a program to calculate the area of a circle.

8. Write a program to find the average of three numbers.

9. How do you check the type of a variable?

10. Write a program to convert kilometers to miles.

Strings

11. Write a program to reverse a string.

12. How do you count vowels in a string?

13. Write a program to check if a string is a palindrome.

14. How do you find the length of a string?

15. Write a program to remove spaces from a string.

Lists

16. Write a program to find the largest number in a list.

17. How do you sort a list in ascending order?

18. Write a program to add an element to a list.

19. Write a program to remove an element from a list.

20. Write a program to count the number of occurrences of an element in a list.


Conditionals

21. Write a program to check if a number is positive, negative, or zero.

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

23. Write a program to find the largest among three numbers.

24. Write a program to check if a year is a leap year.

25. Write a simple calculator (addition, subtraction, multiplication, division).

Loops

26. Write a program to print numbers from 1 to 10 using a for loop.

27. Write a program to print even numbers between 1 and 20.

28. Write a program to calculate the sum of all numbers from 1 to 100.

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

30. Write a program to find the factorial of a number.

Functions

31. Write a function to add two numbers.

32. Write a function to find the maximum of three numbers.

33. Write a function that returns the factorial of a number.

34. Write a function to check if a number is prime.

35. Write a function to count the number of vowels in a string.

Dictionaries and Sets

36. Write a program to create a dictionary with 3 key-value pairs.

37. Write a program to find the value of a key in a dictionary.

38. Write a program to check if a key exists in a dictionary.

39. Write a program to add an item to a set.


40. Write a program to find the intersection of two sets.

File Handling

41. Write a program to create a new text file and write some text into it.

42. Write a program to read the content of a text file.

43. Write a program to append data to an existing file.

44. Write a program to count the number of lines in a text file.

45. Write a program to read a file line by line.

General

46. Write a program to generate a random number between 1 and 100.

47. Write a program to create a list of squares from 1 to 10 using list comprehension.

48. Write a program to check if a list is empty.

49. Write a program to remove duplicates from a list.

50. Write a program to merge two dictionaries.

You might also like