Python: 100 Simple Codes
Beginner-friendly collection of easy-to-understand Python examples.


Each code snippet is designed to help you learn programming concepts step by step, from basic syntax to simple projects. Perfect for students, self-learners, and anyone who wants to practice Python in a fun and practical way.
Codes:

1. Print Hello World

2. Add Two Numbers

3. Check Even or Odd

4. Find Maximum of Two Numbers

5. Simple Calculator

6. Swap Two Variables

7. Check Positive, Negative or Zero

8. Factorial Using Loop

9. Fibonacci Sequence

10. Check Prime Number

===

11. Sum of Numbers in a List

12. Find the Largest Number in a List

13. Count Characters in a String

14. Reverse a String

15. Check Palindrome

16. Generate Random Number

17. Simple While Loop

18. Print Multiplication Table

19. Convert Celsius to Fahrenheit

20. Check Leap Year

===

21. Find GCD (Greatest Common Divisor)

22. Find LCM (Least Common Multiple)

23. Check Armstrong Number

24. Calculate Power (Exponent)

25. Find ASCII Value

26. Convert Decimal to Binary

27. Convert Binary to Decimal

28. Find Square Root

29. Simple Function

30. Function with Parameters

===

31. Function with Default Parameter

32. Return Multiple Values from Function

33. List Comprehension

34. Filter Even Numbers from List

35. Simple Dictionary

36. Loop Through Dictionary

37. Check if Key Exists in Dictionary

38. Use Set to Remove Duplicates

39. Sort a List

40. Sort List in Descending Order

===

41. Create a Tuple

42. Loop Through a Tuple

43. Unpack a Tuple

44. Find Length of a List

45. Append to List

46. Remove from List

47. Pop Last Item from List

48. Use range() in Loop

49. Use break in Loop

50. Use continue in Loop

===

51. Check if List is Empty

52. Join List into String

53. Split String into List

54. Use enumerate() in Loop

55. Nested Loop

56. Simple Class Example

57. Class Inheritance

58. Read Input from User

59. Try-Except for Error Handling

60. Raise Custom Error

===

61. Lambda Function

62. Map Function

63. Filter Function

64. Reduce Function

65. Zip Two Lists

66. List to Dictionary

67. Reverse a List

68. Sort List of Tuples by Second Value

69. Flatten Nested List

70. Count Occurrences in List

===

71. Check All Elements with all()

72. Check Any Element with any()

73. Find Index in List

74. Convert List to Set

75. Find Intersection of Sets

76. Find Union of Sets

77. Find Difference of Sets

78. Check Subset

79. Check Superset

80. Loop with Else Clause

===

81. Use pass Statement

82. Use del to Delete Item

83. Check Type of Variable

84. Format String with f-string

85. Simple List Slicing

86. Nested If Statement

87. Global Variable

88. Check if String Contains Substring

89. Count Characters in Dictionary

90. Create 2D List

===

91. Check if List Contains Item

92. Reverse a Number

93. Sum of Digits

94. Check Perfect Number

95. Simple Countdown

96. Print Pattern with Stars

97. Check if String is Digit

98. Check if All Letters Are Uppercase

99. Simple Timer with Sleep

100. Basic File Write and Read

===