️ DEPRECATED GITLAB INSTANCE ️ This GitLab is now read-only for reference. Please use https://gitlab.iauro.co for all new work.

Migration completed on September 17, 2025

Commit 0b098fde authored by Ajay Kamble's avatar Ajay Kamble

resolved merge confict

parent ace29010
__pycache__/
*.pyc
.venv/
*.log
\ No newline at end of file
# Calculator Script
## Overview
The `calculator.py` script is a command-line tool that performs basic arithmetic operations (addition, subtraction, multiplication, division, modulus, exponentiation, and floor division) on two user-provided numbers. It includes input validation and allows users to continue or exit calculations.
## Features
- Supports seven arithmetic operations:
- Addition
- Subtraction
- Multiplication
- Division
- Modulus
- Exponentiation
- Floor division
- Validates numeric inputs and operation selections
- Handles division by zero
- Allows users to continue or exit via a prompt
## Requirements
- Python 3.8 or higher
- No additional dependencies (uses standard library)
## Setup Instructions
1. **Run the script**:
```bash
python calculator.py
```
## Usage
1. Run the script using the command above.
2. Enter the first number when prompted.
3. Enter the second number.
4. Select an operation by entering a number (1–7) corresponding to the displayed menu.
5. View the result of the calculation.
6. Choose to continue (`Yes`, `yes`, `y`, or `Y`) or exit (any other input).
7. If invalid inputs are provided (e.g., non-numeric values), an error message will prompt for valid input.
## Example
```plaintext
Enter the first Number: 10
Enter the Second Number: 5
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Modulus
6. Exponentiation
7. Floor division
Enter the Operation Number (1-7): 1
15
Do you want to continue the calculation (Yes/No): Yes
...
Do you want to continue the calculation (Yes/No): No
Thank you!
```
while True:
try:
a = int(input("Enter the first Number: "))
b = int(input("Enter the Second Number: "))
print("1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Modulus\n6. Exponentiation\n7. Floor division")
Operation_number = int(input("Enter the Operation Number (1-7): "))
if Operation_number == 1:
print(a + b)
elif Operation_number == 2:
print(a - b)
elif Operation_number == 3:
print(a * b)
elif Operation_number == 4:
if b != 0:
print(a / b)
else:
print("Cannot divide by zero")
elif Operation_number == 5:
if b != 0:
print(a % b)
else:
print("Cannot compute modulus with zero")
elif Operation_number == 6:
print(a ** b)
elif Operation_number == 7:
if b != 0:
print(a // b)
else:
print("Cannot divide by zero")
else:
print("Invalid arithmetic operation selected. Please choose a number between 1 and 7.")
s = input("Do you want to continue the calculation (Yes/No): ")
if s not in ["Yes", "yes", "y", "Y"]:
print("Thank you!")
break
except ValueError:
print("Invalid input. Please enter valid numbers.")
\ No newline at end of file
# MODULE_1: GEN-AI Module-1
## Overview
The `MODULE_1` directory contains three standalone Python command-line tools: a calculator, a file parser, and a student management system. Each tool is located in its own subdirectory with its own `README.md` file for detailed instructions.
## Project Structure
```plaintext
MODULE_1/
├── Calculator/
│ ├── calculator.py # Arithmetic calculator script
│ └── README.md # Documentation for calculator.py
├── file_parse/
│ ├── file.py # File parser CLI tool
│ ├── README.md # Documentation for file.py
│ └── sample.txt # Sample text file for parsing
└── SMS/
├── README.md # Documentation for sms.py
└── sms.py # Student Management System script
```
## Tools Overview
1. **Calculator** (`Calculator/calculator.py`):
- A command-line tool for performing basic arithmetic operations (addition, subtraction, multiplication, division, modulus, exponentiation, and floor division).
- Features input validation and the ability to continue or exit calculations.
2. **File Parser** (`file_parse/file.py`):
- A command-line tool for parsing text files, with functionality to count lines, words, and characters, search for keywords, and extract line ranges.
- Includes a sample text file (`sample.txt`) for testing.
3. **Student Management System** (`SMS/sms.py`):
- A command-line tool for managing student records, allowing users to add, remove, search, and display student information with validation for IDs, ages, and grades.
## Requirements
- Python 3.8 or higher
- No additional dependencies (all scripts use the Python standard library)
## Setup Instructions
1. **Clone or download the repository**:
- If using Git, clone the repository:
```bash
git clone <repo-url>
cd MODULE_1
```
- Alternatively, download and extract the `MODULE_1` directory.
2. **Navigate to a tool’s directory**:
- Each tool has its own directory (`Calculator`, `file_parse`, or `SMS`).
- Refer to the `README.md` in each directory for specific instructions.
3. **Run a script**:
- Navigate to the desired tool’s directory and run the script. For example:
```bash
cd Calculator
python calculator.py
```
- See each tool’s `README.md` for detailed usage instructions.
## Usage
- Each tool is independent and can be run directly from its directory.
- Refer to the individual `README.md` files for detailed examples and instructions:
- `Calculator/README.md`
- `file_parse/README.md`
- `SMS/README.md`
# Gen-AI upskilling-program-Assignments # Gen-AI upskilling-program-Assignments
# Student Management System
## Overview
The `sms.py` script is a command-line tool for managing student records. It allows users to add, remove, search, and display student information, with validation for student ID, age, and grade.
## Features
- Add a student with a unique ID, name, age, and grade
- Remove a student by ID
- Search for a student by ID
- Display all students
- Validates:
- Student ID (positive integer)
- Age (1–120)
- Grade (A, B, C, D, or F)
- Prevents duplicate student IDs
## Requirements
- Python 3.8 or higher
- No additional dependencies (uses standard library)
## Setup Instructions
**Run the script**:
```bash
python sms.py
```
## Usage
1. Run the script using the command above.
2. Select an option from the menu (1–5):
- 1: Add a new student
- 2: Remove a student by ID
- 3: Search for a student by ID
- 4: Display all students
- 5: Exit
3. Follow prompts for specific actions (e.g., enter student details or ID).
4. Input validation ensures valid student IDs, ages, grades, and non-empty names.
5. Appropriate messages are displayed for successful actions or errors (e.g., duplicate ID, student not found).
## Example
```plaintext
Student Management System
1. Add Student
2. Remove Student
3. Search Student
4. Display All Students
5. Exit
Choose an option (1-5): 1
Add New Student
Enter student ID: 1
Enter name: Ajay K
Enter age: 21
Enter grade (A, B, C, D, F): A
Student Ajay K added successfully!
...
Choose an option (1-5): 4
All Students:
ID: 1, Name: Ajay K, Age: 21, Grade: A
...
Choose an option (1-5): 5
Goodbye!
```
class Student:
def __init__(self, student_id, name, age, grade):
self.student_id = student_id
self.name = name
self.age = age
self.grade = grade
def display_info(self):
print(f"ID: {self.student_id}, Name: {self.name}, Age: {self.age}, Grade: {self.grade}")
class StudentManagementSystem:
def __init__(self):
self.students = []
def add_student(self, student):
for s in self.students:
if s.student_id == student.student_id:
print(f"Student ID {student.student_id} already exists.")
return
self.students.append(student)
print(f"Student {student.name} added successfully!")
def remove_student(self, student_id):
for i, s in enumerate(self.students):
if s.student_id == student_id:
removed = self.students.pop(i)
print(f"Student {removed.name} removed successfully!")
return
print("Student not found.")
def display_all_students(self):
if not self.students:
print("No students in the system.")
else:
print("\nAll Students:")
for s in self.students:
s.display_info()
def search_student(self, student_id):
for s in self.students:
if s.student_id == student_id:
print("Student found:")
s.display_info()
return
print("Student not found.")
def get_valid_id():
while True:
try:
student_id = int(input("Enter student ID: "))
if student_id > 0:
return student_id
print("ID must be a positive number.")
except ValueError:
print("Please enter a valid number.")
def get_valid_age():
while True:
try:
age = int(input("Enter age: "))
if 1 <= age <= 120:
return age
print("Age must be between 1 and 120.")
except ValueError:
print("Please enter a valid number.")
def get_valid_grade():
grades = ['A', 'B', 'C', 'D', 'F']
while True:
grade = input("Enter grade (A, B, C, D, F): ").strip().upper()
if grade in grades:
return grade
print("Grade must be A, B, C, D, or F.")
def main():
system = StudentManagementSystem()
while True:
print("\nStudent Management System")
print("1. Add Student")
print("2. Remove Student")
print("3. Search Student")
print("4. Display All Students")
print("5. Exit")
choice = input("Choose an option (1-5): ").strip()
if choice == '1':
print("\nAdd New Student")
student_id = get_valid_id()
name = input("Enter name: ").strip()
if not name:
print("Name cannot be empty.")
continue
age = get_valid_age()
grade = get_valid_grade()
student = Student(student_id, name, age, grade)
system.add_student(student)
elif choice == '2':
print("\nRemove Student")
student_id = get_valid_id()
system.remove_student(student_id)
elif choice == '3':
print("\nSearch Student")
student_id = get_valid_id()
system.search_student(student_id)
elif choice == '4':
system.display_all_students()
elif choice == '5':
print("Goodbye!")
break
else:
print("Please enter a number from 1 to 5.")
if __name__ == "__main__":
main()
# File Parser CLI Tool
## Overview
The `file.py` script is a command-line tool for parsing text files. It allows users to count lines, words, and characters, search for keywords, and extract specific line ranges from a text file.
## Features
- Count total lines in a file
- Count total words in a file
- Count total characters (including spaces and newlines)
- Search for a keyword (case-insensitive) and display matching lines
- Extract and display a range of lines
- Handles file not found errors and invalid inputs
## Requirements
- Python 3.8 or higher
- No additional dependencies (uses standard library)
## Setup Instructions
1. **Ensure the script and text file are available**:
- Place `file.py` in desired directory.
- Have a text file (e.g., `sample.txt`) ready in a known location.
2. **Run the script**:
```bash
python file.py
```
## Usage
1. Run the script using the command above.
2. Enter the path to the text file when prompted (e.g., `sample.txt` or `/path/to/sample.txt`).
3. Select an option from the menu (1–6):
- 1: Count total lines
- 2: Count total words
- 3: Count total characters
- 4: Search for a keyword
- 5: Extract a range of lines
- 6: Exit
4. Follow prompts for specific actions (e.g., enter a keyword or line numbers).
5. If the file is not found or invalid inputs are provided, appropriate error messages will be displayed.
## Example
```plaintext
Welcome to File Parser CLI Tool
Enter the path to the text file: sample.txt
Menu
1. Count Lines
2. Count Words
3. Count Characters
4. Search Keyword
5. Extract Lines
6. Exit
Choose an option (1-6): 1
Total lines: 10
...
Choose an option (1-6): 4
Enter keyword to search: hello
Line 3: hello world
Line 7: Hello there
...
Choose an option (1-6): 6
Goodbye!
```
class FileParser:
def __init__(self, file_path):
self.file_path = file_path
try:
with open(file_path, 'r', encoding='utf-8') as f:
self.lines = f.readlines()
except FileNotFoundError:
print(f"File '{file_path}' not found.")
self.lines = []
def count_lines(self):
print(f"Total lines: {len(self.lines)}")
def count_words(self):
word_count = sum(len(line.split()) for line in self.lines)
print(f"Total words: {word_count}")
def count_characters(self):
char_count = sum(len(line) for line in self.lines)
print(f"Total characters: {char_count}")
def search_keyword(self, keyword):
found = False
for i, line in enumerate(self.lines, start=1):
if keyword.lower() in line.lower():
print(f"Line {i}: {line.strip()}")
found = True
if not found:
print(f"No matches found for '{keyword}'.")
def extract_lines(self, start, end):
if start < 1 or end > len(self.lines) or start > end:
print("Invalid line range.")
return
print(f"\nExtracting lines {start} to {end}:")
for i in range(start - 1, end):
print(f"Line {i+1}: {self.lines[i].strip()}")
def main():
print("Welcome to File Parser CLI Tool")
file_path = input("Enter the path to the text file: ").strip()
parser = FileParser(file_path)
if not parser.lines:
return # Exit if file could not be loaded
while True:
print("\nMenu")
print("1. Count Lines")
print("2. Count Words")
print("3. Count Characters")
print("4. Search Keyword")
print("5. Extract Lines")
print("6. Exit")
choice = input("Choose an option (1-6): ").strip()
if choice == '1':
parser.count_lines()
elif choice == '2':
parser.count_words()
elif choice == '3':
parser.count_characters()
elif choice == '4':
keyword = input("Enter keyword to search: ").strip()
parser.search_keyword(keyword)
elif choice == '5':
try:
start = int(input("Enter start line number: "))
end = int(input("Enter end line number: "))
parser.extract_lines(start, end)
except ValueError:
print("Please enter valid line numbers.")
elif choice == '6':
print("Goodbye!")
break
else:
print("Please enter a number from 1 to 6.")
if __name__ == "__main__":
main()
He slowly poured the drink over a large chunk of ice he has especially chiseled off a larger block. He didn't particularly like his drinks cold, but he knew that the drama of chiseling the ice and then pouring a drink over it looked far more impressive than how he actually liked it. It was all about image and he'd managed to perfect the image that he wanted to project.
Green vines attached to the trunk of the tree had wound themselves toward the top of the canopy. Ants used the vine as their private highway, avoiding all the creases and crags of the bark, to freely move at top speed from top to bottom or bottom to top depending on their current chore. At least this was the way it was supposed to be. Something had damaged the vine overnight halfway up the tree leaving a gap in the once pristine ant highway.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment