Task-1 Odd or Even Number Checker This is a simple Python program that checks whether a given integer is odd or even. It's a beginner-friendly script that demonstrates the use of basic input, conditionals, and the modulo operator in Python.
๐ How It Works The user is prompted to enter an integer.
The program checks if the number is divisible by 2 using the modulo (%) operator.
It prints whether the number is even or odd.
๐งพ Sample Output bash Copy Edit Enter an integer: 7 7 is an odd number. bash Copy Edit Enter an integer: 12 12 is an even number. ๐ง Concepts Used input() function
Type casting (int)
Conditional statements (if-else)
Modulo operator (%)
๐ How to Run Make sure you have Python installed (preferably Python 3).
Clone this repo or copy the code into a .py file.
Open your terminal and run:
bash Copy Edit python filename.py Replace filename.py with the name of your Python file.
๐ค Contributing Feel free to fork this repo and play around with the logic, maybe extend it to handle floats or validate input!
TASK 2โ Sum of First 50 Positive Integers This is a simple Python script that calculates the sum of the first 50 positive integers (i.e., numbers from 1 to 50). It's a great beginner exercise for practicing loops and basic arithmetic operations.
๐ก What It Does The program:
Initializes a variable total_sum to 0.
Uses a for loop to iterate from 1 to 50.
Adds each number to total_sum.
Prints the final result.
๐งพ Output Example bash Copy Edit The sum of numbers from 1 to 50 is: 1275 ๐ง Concepts Covered for loop
range() function
Variables and arithmetic operations
print() formatting
๐ How to Run the Code Make sure you have Python installed.
Clone this repo or copy the code into a file like sum_first_50.py.
Open your terminal and run
bash Copy Edit python sum_first_50.py
summary These two Python scripts are simple beginner-level programs. The first checks whether a given integer is odd or even using the modulo operator, while the second calculates the sum of the first 50 positive integers using a loop. Both tasks help in understanding basic concepts like loops, conditionals, user input, and arithmetic operations in Python.