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

10 Python Programs

The document provides a series of Python code snippets demonstrating basic arithmetic operations, conditional statements, loops, and input handling. It includes examples for checking even or odd numbers, finding the greatest of two numbers, determining pass or fail based on marks, and printing sequences of numbers. Each section is clearly labeled and illustrates fundamental programming concepts in Python.

Uploaded by

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

10 Python Programs

The document provides a series of Python code snippets demonstrating basic arithmetic operations, conditional statements, loops, and input handling. It includes examples for checking even or odd numbers, finding the greatest of two numbers, determining pass or fail based on marks, and printing sequences of numbers. Each section is clearly labeled and illustrates fundamental programming concepts in Python.

Uploaded by

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

1 Arithmetic Operations (Operators)

1. 1️⃣
2. a = int(input("Enter first number: "))
3. b = int(input("Enter second number: "))
4.
5. print("Sum =", a + b)
6. print("Difference =", a - b)
7. print("Product =", a * b)
8. print("Quotient =", a / b)
9.
10.

11. 2️⃣Check Even or Odd (Operator + If-Else)


12. num = int(input("Enter a number: "))
13.
14. if num % 2 == 0:
15. print("Even Number")
16. else:
17. print("Odd Number")
18.
19.

20. 3️⃣Find Greatest of Two Numbers (If-Else)


21. a = int(input("Enter first number: "))
22. b = int(input("Enter second number: "))
23.
24. if a > b:
25. print("Greatest number:", a)
26. else:
27. print("Greatest number:", b)
28.
29.

30. 4️⃣Check Pass or Fail (If-Else)


31. marks = int(input("Enter marks: "))
32.
33. if marks >= 33:
34. print("Pass")
35. else:
36. print("Fail")
37.
38.
39. 5️⃣Check Positive, Negative or Zero
40. num = int(input("Enter a number: "))
41.
42. if num > 0:
43. print("Positive")
44. elif num < 0:
45. print("Negative")
46. else:
47. print("Zero")
48.
49.

50. 6️⃣Print Numbers from 1 to 10 (For Loop)


51. for i in range(1, 11):
52. print(i)
53.
54.

55. 7️⃣Multiplication Table of a Number


56. n = int(input("Enter a number: "))
57.
58. for i in range(1, 11):
59. print(n, "x", i, "=", n * i)
60.
61.

62. 8️⃣Sum of First n Natural Numbers


63. n = int(input("Enter value of n: "))
64. sum = 0
65.
66. for i in range(1, n + 1):
67. sum = sum + i
68.
69. print("Sum =", sum)
70.
71.

72. 9️⃣Print Even Numbers from 1 to 20


73. for i in range(2, 21, 2):
74. print(i)
75.
76.
77. 🔟 Print Numbers Using While Loop
78. i = 1
79. while i <= 5:
80. print(i)
81. i=i+1
82.

You might also like