This repository includes beginner Python scripts focusing on basic concepts, control structures, functions, modules, file handling, and data structures.
-
Mathematical Operations:
Prompts the user for two numbers, calculates and displays their sum, difference, product, and division. Demonstrates arithmetic operators and simple input/output. -
Personalized Greeting:
Takes first and last name input, combines them, and prints a greeting message to the user.
- Make sure Python is installed.
- Open terminal/command prompt.
- Navigate to the script directory.
- Run each program using:
python task1_basic_math.py python task2_greeting.py
-
Even/Odd Number Checker:
Asks for an integer input and uses an if-else statement to check if the number is even or odd. -
Sum of Numbers (1 to 50):
Calculates and prints the sum of all integers from 1 to 50 using a for loop.
- Confirm Python is installed.
- Open terminal/command prompt and go to the project directory.
- Run the scripts using:
python check_even_odd.py python sum_1_to_50.py
-
Factorial Calculator:
Defines a function to calculate the factorial of a number using recursion or loops. -
Math Module Calculations:
Uses Python's built-in math module to compute square root, natural logarithm, and sine of a user-entered number.
- Ensure Python is installed.
- Open terminal/command prompt.
- Navigate to the project folder.
- Run the scripts with:
python factorial_function.py python math_module_calculations.py
-
Read File with Error Handling:
Opens and reads a file namedsample.txt
. Prints its contents line by line and handles errors if the file does not exist. -
Write and Append Data to a File:
Takes user input to write to a file, appends additional data, then reads and displays the complete file contents.
- Verify Python is installed on your system.
- Open terminal or command prompt and navigate to your project folder.
- Execute:
python read_file.py python write_append_file.py
-
Student Marks Lookup:
Implements a dictionary where student names are keys and their marks are values. The user can input a student's name to retrieve marks, with proper handling for missing entries. -
List Slicing Demonstration:
Creates a list of numbers from 1 to 10, extracts the first five elements, reverses them, and displays both the extracted and reversed lists.
- Make sure Python is installed.
- Open terminal/command prompt and go to the project folder.
- Run the scripts using:
python student_marks_dictionary.py python list_slicing_demo.py
Note:
These scripts are designed for interactive, beginner-friendly learning of essential Python programming concepts.