️ 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 c8aa6e1f authored by Priti Pawar's avatar Priti Pawar

modules added

parents
{
"courseTypes": [
{
"name": "E-Learning",
"value": "E-Learning"
},
{
"name":"Regular Learning",
"value":"You can create a full-fledged learning course using this type. This will help to make an objective based learning"
},
{
"name":"Micro-learning",
"value":"You can create a quick course to share a document,video or any web article with others. This can be created for general information sharing purpose"
},
{
"name":"Assessment",
"value":"You can create a practice assessment using this type"
},
{
"name":"Classroom Learning",
"value":"You can create a full-fledged learning course using this type. This will help to make an objective based learning"
}
]
}
\ No newline at end of file
import argparse
import os
import json
import csv
def parse_txt(file_path):
print("Parsing TXT file:")
with open(file_path, 'r') as file:
for line in file:
print(line.strip())
def parse_json(file_path):
print("Parsing JSON file:")
with open(file_path, 'r') as file:
data = json.load(file)
print(json.dumps(data, indent=4))
def parse_csv(file_path):
print("Parsing CSV file:")
with open(file_path, 'r') as file:
reader = csv.reader(file)
for row in reader:
print(row)
def main():
parser = argparse.ArgumentParser(description="Simple File Parser CLI Tool")
parser.add_argument("file", help="Path to the file to parse")
args = parser.parse_args()
file_path = args.file
if not os.path.isfile(file_path):
print("Error: File does not exist.")
return
ext = os.path.splitext(file_path)[1].lower()
if ext == ".txt":
parse_txt(file_path)
elif ext == ".json":
parse_json(file_path)
elif ext == ".csv":
parse_csv(file_path)
else:
print("Unsupported file type.")
if __name__ == "__main__":
main()
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
if y == 0:
return "Error! Division by zero."
return x / y
def power(x, y):
return x ** y
def calculator():
print("Welcome to Python Calculator!")
print("Select operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print("5. Power (x^y)")
choice = input("Enter choice (1-5): ")
if choice not in ['1', '2', '3', '4', '5']:
print("Invalid input.")
return
try:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
except ValueError:
print("Invalid input. Please enter numbers.")
return
if choice == '1':
print(f"Result: {add(num1, num2)}")
elif choice == '2':
print(f"Result: {subtract(num1, num2)}")
elif choice == '3':
print(f"Result: {multiply(num1, num2)}")
elif choice == '4':
print(f"Result: {divide(num1, num2)}")
elif choice == '5':
print(f"Result: {power(num1, num2)}")
# Run the calculator
calculator()
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(self):
print(f"ID: {self.student_id}, Name: {self.name}, Age: {self.age}, Grade: {self.grade}")
class StudentManager:
def __init__(self):
self.students = []
def add_student(self, student):
self.students.append(student)
print("Student added successfully.")
def remove_student(self, student_id):
for s in self.students:
if s.student_id == student_id:
self.students.remove(s)
print("Student removed.")
return
print("Student not found.")
def view_students(self):
if not self.students:
print("No students found.")
return
print("\n--- Student List ---")
for s in self.students:
s.display()
def search_student(self, student_id):
for s in self.students:
if s.student_id == student_id:
print("Student found:")
s.display()
return
print("Student not found.")
def menu():
manager = StudentManager()
while True:
print("\n--- Student Management System ---")
print("1. Add Student")
print("2. Remove Student")
print("3. View All Students")
print("4. Search Student by ID")
print("5. Exit")
choice = input("Enter your choice: ")
if choice == '1':
sid = input("Enter Student ID: ")
name = input("Enter Name: ")
age = input("Enter Age: ")
grade = input("Enter Grade: ")
student = Student(sid, name, age, grade)
manager.add_student(student)
elif choice == '2':
sid = input("Enter Student ID to remove: ")
manager.remove_student(sid)
elif choice == '3':
manager.view_students()
elif choice == '4':
sid = input("Enter Student ID to search: ")
manager.search_student(sid)
elif choice == '5':
print("Exiting...")
break
else:
print("Invalid choice! Please select 1-5.")
if __name__ == "__main__":
menu()
from flask import Flask, render_template, redirect, request, url_for, jsonify
from flask_login import LoginManager, login_user, login_required, logout_user, current_user
from flask_socketio import SocketIO, emit
from werkzeug.security import generate_password_hash, check_password_hash
from models import db, User, Task
from flask import Flask
app = Flask(__name__)
app.secret_key = 'supersecretkey'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
db.init_app(app)
socketio = SocketIO(app)
login_manager = LoginManager(app)
login_manager.login_view = 'login'
@login_manager.user_loader
def load_user(user_id):
return User.query.get(int(user_id))
@app.before_first_request
def create_tables():
db.create_all()
@app.route('/')
def home():
return redirect(url_for('login'))
@app.route('/register', methods=['GET', 'POST'])
def register():
if request.method == 'POST':
username = request.form['username']
password = generate_password_hash(request.form['password'])
if not User.query.filter_by(username=username).first():
db.session.add(User(username=username, password=password))
db.session.commit()
return redirect(url_for('login'))
return render_template('register.html')
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
user = User.query.filter_by(username=request.form['username']).first()
if user and check_password_hash(user.password, request.form['password']):
login_user(user)
return redirect(url_for('dashboard'))
return render_template('login.html')
@app.route('/dashboard')
@login_required
def dashboard():
tasks = Task.query.filter_by(user_id=current_user.id).all()
return render_template('dashboard.html', tasks=tasks)
@app.route('/add_task', methods=['POST'])
@login_required
def add_task():
title = request.form['title']
task = Task(title=title, user_id=current_user.id)
db.session.add(task)
db.session.commit()
socketio.emit('new_task', {'title': title}, broadcast=True)
return redirect(url_for('dashboard'))
@app.route('/toggle/<int:task_id>')
@login_required
def toggle(task_id):
task = Task.query.get_or_404(task_id)
if task.user_id == current_user.id:
task.is_done = not task.is_done
db.session.commit()
socketio.emit('update_task', {'id': task.id, 'is_done': task.is_done}, broadcast=True)
return redirect(url_for('dashboard'))
@app.route('/logout')
def logout():
logout_user()
return redirect(url_for('login'))
if __name__ == '__main__':
socketio.run(app, debug=True)
from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin
db = SQLAlchemy()
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
password = db.Column(db.String(120), nullable=False)
class Task(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(200), nullable=False)
is_done = db.Column(db.Boolean, default=False)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashboard - Task Manager</title>
<script src="https://cdn.socket.io/4.6.1/socket.io.min.js" integrity="sha384-PW7ybO5sz+Jop+Ws5aq9YflPG56Jej81s5OKhEF7Wy6b4qzQ3a1Tf95hT4I6LDsn" crossorigin="anonymous"></script>
</head>
<body>
<h2>Welcome, {{ current_user.username }}</h2>
<h3>Add New Task</h3>
<form action="{{ url_for('add_task') }}" method="POST">
<input type="text" name="title" placeholder="Enter task title" required>
<button type="submit">Add Task</button>
</form>
<h3>Your Tasks</h3>
<ul>
{% for task in tasks %}
<li>
<form action="{{ url_for('toggle', task_id=task.id) }}" method="GET" style="display:inline;">
<button type="submit">{{ '✅' if task.is_done else '⬜️' }}</button>
</form>
{{ task.title }}
</li>
{% else %}
<li>No tasks yet.</li>
{% endfor %}
</ul>
<p><a href="{{ url_for('logout') }}">Logout</a></p>
<script>
const socket = io();
socket.on('new_task', (data) => {
alert("🔔 New Task Added: " + data.title);
location.reload();
});
socket.on('update_task', (data) => {
console.log("Task updated:", data);
location.reload();
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login - Task Manager</title>
</head>
<body>
<h2>Login</h2>
<form method="POST">
<label>Username:</label><br>
<input type="text" name="username" required><br><br>
<label>Password:</label><br>
<input type="password" name="password" required><br><br>
<button type="submit">Login</button>
</form>
<p>Don't have an account? <a href="{{ url_for('register') }}">Register</a></p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Register - Task Manager</title>
</head>
<body>
<h2>Register</h2>
<form method="POST">
<label>Username:</label><br>
<input type="text" name="username" required><br><br>
<label>Password:</label><br>
<input type="password" name="password" required><br><br>
<button type="submit">Register</button>
</form>
<p>Already have an account? <a href="{{ url_for('login') }}">Login</a></p>
</body>
</html>
<script src="//cdn.socket.io/4.0.0/socket.io.min.js"></script>
<script>
const socket = io();
socket.on('new_task', (data) => {
alert("New Task Added: " + data.title);
location.reload();
});
socket.on('update_task', (data) => {
console.log("Task updated", data);
location.reload();
});
</script>
import streamlit as st
import yfinance as yf
import pandas as pd
import re
from collections import Counter
# --- Frequency-based text summarizer ---
def summarize_text(text, max_sentences=3):
stopwords = set([
"the", "is", "in", "and", "to", "of", "for", "a", "an", "on",
"this", "that", "it", "as", "at", "be"
])
sentences = re.split(r'(?<=[.!?]) +', text.strip())
if not sentences:
return ""
words = [w.lower() for w in re.findall(r"\w+", text)
if w.lower() not in stopwords]
if not words:
return sentences[0]
frequencies = Counter(words)
rankings = []
for idx, sentence in enumerate(sentences):
word_list = [w.lower() for w in re.findall(r'\w+', sentence)]
score = sum(frequencies.get(w, 0) for w in word_list)
rankings.append((score, idx, sentence))
top_sentences = sorted(rankings, reverse=True)[:max_sentences]
top_sentences.sort(key=lambda x: x[1]) # Preserve original order
return " ".join([s[2] for s in top_sentences])
# --- Streamlit Page Configuration ---
st.set_page_config(page_title="Stock Dashboard", layout="centered")
st.title("Stock Price Dashboard & Text Summarizer")
# --- Sidebar for user inputs ---
st.sidebar.header("Stock Configuration")
ticker = st.sidebar.text_input("Enter Stock Ticker", "AAPL")
period = st.sidebar.selectbox(
"Select Period", ["1mo", "3mo", "6mo", "1y", "2y", "5y"], index=3)
interval = st.sidebar.selectbox(
"Select Interval", ["1d", "1wk", "1mo"], index=0)
# --- Download stock data ---
@st.cache_data
def load_data(ticker, period, interval):
try:
return yf.download(ticker, period=period, interval=interval)
except Exception:
return pd.DataFrame()
data = load_data(ticker, period, interval)
# --- Show Stock Chart ---
st.subheader(f"Price Chart for: {ticker.upper()}")
if not data.empty and "Close" in data.columns:
st.line_chart(data["Close"])
latest_close = float(data["Close"].iloc[-1])
high_value = float(data["High"].max())
low_value = float(data["Low"].min())
st.metric("Latest Close", f"${latest_close:.2f}")
st.metric("High", f"${high_value:.2f}")
st.metric("Low", f"${low_value:.2f}")
else:
st.warning("No valid stock data available for this ticker or time range.")
# --- Text Summarization Section ---
st.subheader("Stock-related Text Summarization")
text_input = st.text_area("Enter news or analysis related to this stock:")
max_sentences = st.slider("Max Sentences in Summary",
min_value=1, max_value=5, value=3)
if st.button("Summarize"):
if text_input.strip():
summary = summarize_text(text_input, max_sentences)
st.success("Summary:")
st.write(summary)
else:
st.warning("Please enter some text to summarize.")
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