Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Commit 19875de

Browse files
Add files via upload
1 parent ce75360 commit 19875de

File tree

6 files changed

+208
-0
lines changed

6 files changed

+208
-0
lines changed

‎Naga Sathvik Rapelli/Task 5/task5.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from flask import Flask, render_template, request
2+
import requests
3+
4+
app = Flask(__name__)
5+
6+
api_key = "fe35e3bb6b21c465def7ea465e765f7f"
7+
8+
def get_weather(city):
9+
url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric"
10+
response = requests.get(url)
11+
data = response.json()
12+
return data
13+
14+
15+
@app.route('/', methods=['GET', 'POST'])
16+
def home():
17+
if request.method == 'POST':
18+
city = request.form['city']
19+
weather_data = get_weather(city)
20+
return render_template('index.html', show_weather=True, weather_data=weather_data)
21+
else:
22+
return render_template('index.html', show_weather=False)
23+
24+
25+
if __name__ == '__main__':
26+
app.run(debug=True)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Weather App</title>
7+
<style>
8+
body {
9+
background-color: cornsilk;
10+
display: flex;
11+
justify-content: center;
12+
align-items: center;
13+
height: 100vh;
14+
margin: 0;
15+
}
16+
.container {
17+
text-align: center;
18+
padding: 20px;
19+
border-radius: 10px;
20+
background-color: white;
21+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
22+
}
23+
</style>
24+
</head>
25+
<body>
26+
<div class="container">
27+
<h1>Weather App</h1>
28+
<form action="/" method="post">
29+
<label for="city">Enter city name:</label>
30+
<input type="text" id="city" name="city" />
31+
<button type="submit">Get Weather</button>
32+
</form>
33+
34+
{% if show_weather %}
35+
<h2>Weather Report for {{ weather_data['name'] }}</h2>
36+
<p>Temperature: {{ weather_data['main']['temp'] }}°C</p>
37+
<p>Weather: {{ weather_data['weather'][0]['description'] }}</p>
38+
{% endif %}
39+
</div>
40+
</body>
41+
</html>

‎Naga Sathvik Rapelli/Task 6/data.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Title,Description
2+
HTML 5 Tutorial,HTML stands for HyperText Markup Language. It's the regular code used to make web pages. HTML has certain pre-made parts that help in building the structure and content of the webpage.
3+
JavaScript Tutorial,"JavaScript is a high-level, dynamic programming language commonly used for web development to create interactive and dynamic web pages."
4+
React JS Tutorial,"React is an open-source JavaScript library for building user interfaces, commonly used for creating interactive and dynamic web applications."
5+
Node JS Tutorial,"Node.js is free, server-side JavaScript runtime environment that allows coders to execute JavaScript code outside of a web browser.Node.js is a JavaScript runtime built on the V8 JavaScript engine."
6+
MongoDB Tutorial,"MongoDB is a popular open-source NoSQL (non-relational) database management system. It stores data in a flexible, semi-structured BSON format, which is similar to JSON."

‎Naga Sathvik Rapelli/Task 6/task6.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
import csv
4+
5+
def scrape_website(url, filename):
6+
response = requests.get(url)
7+
if response.status_code != 200:
8+
print(f"Failed to fetch {url}. Status code: {response.status_code}")
9+
return
10+
11+
soup = BeautifulSoup(response.content, 'html.parser')
12+
13+
data_list = []
14+
for card in soup.find_all('div', class_='card'):
15+
title_element = card.find('div', class_='title').find('h3')
16+
description_element = card.find('div', class_='matter').find('p')
17+
if title_element and description_element:
18+
title = title_element.text.strip()
19+
description = description_element.text.strip()
20+
data_list.append([title, description])
21+
else:
22+
print("Missing title or description in card")
23+
24+
if not data_list:
25+
print("No data found on the page")
26+
return
27+
28+
with open(filename, 'w', newline='', encoding='utf-8') as csvfile:
29+
writer = csv.writer(csvfile)
30+
writer.writerow(['Title', 'Description'])
31+
writer.writerows(data_list)
32+
33+
print(f"Data scraped successfully and saved to {filename}")
34+
35+
url = 'https://www.webstacknotes.com/'
36+
filename = 'data.csv'
37+
scrape_website(url, filename)

‎Naga Sathvik Rapelli/Task 7/task7.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Define responses based on user input
2+
responses = {
3+
"hi": "Hello! How can I help you?",
4+
"how are you?": "I'm doing well, thank you!",
5+
"bye": "Goodbye! Have a great day!",
6+
"how can I assist you?": "I'm here to help you with any questions or tasks you have.",
7+
"what's up?": "Not much, just here to chat and assist you.",
8+
"how's it going?": "It's going well! Thanks for asking.",
9+
"what's new?": "Not much, just ready to help you out.",
10+
"what can you do?": "I can answer questions, provide information, and assist with various tasks.",
11+
"tell me about yourself": "I'm a chatbot designed to assist you with your inquiries and tasks.",
12+
"who created you?": "I was created by a team of developers to assist users like you.",
13+
"where are you from?": "I exist in the digital realm to provide assistance to users like yourself.",
14+
"what's your favorite color?": "I don't have a favorite color, but I'm here to assist you with any questions you have.",
15+
"do you have any hobbies?": "As a chatbot, I don't have hobbies, but I'm here to assist you with your queries.",
16+
"are you a robot?": "Yes, I am a chatbot designed to assist you with your inquiries.",
17+
"are you human?": "No, I am an artificial intelligence programmed to assist users like yourself.",
18+
"what languages do you speak?": "I can communicate in various human languages to assist you.",
19+
"can you help me?": "Yes, I'm here to assist you with any questions or tasks you have.",
20+
"what's the meaning of life?": "That's a philosophical question! Many people have different interpretations of the meaning of life.",
21+
"do you dream?": "As a chatbot, I don't dream, but I'm here to help you with your questions.",
22+
"how do I use this?": "You can interact with me by typing your questions or commands, and I'll do my best to assist you.",
23+
"where can I find help?": "You can ask me questions, or you can seek assistance from human support if needed.",
24+
"can I trust you?": "Yes, you can trust me to provide accurate information and assistance to the best of my ability.",
25+
"are you intelligent?": "As an artificial intelligence, I'm designed to assist you by providing relevant information and assistance.",
26+
"what's the weather like?": "I can help you check the weather in your area if you provide me with your location.",
27+
"how do I contact support?": "You can usually find contact information for support on the website or app you're using.",
28+
"can you sing?": "I'm not programmed to sing, but I can assist you with your inquiries.",
29+
"do you have any siblings?": "As a chatbot, I don't have siblings, but I'm here to assist you with your questions.",
30+
"what's your favorite food?": "I don't eat, but I'm here to assist you with any questions you have.",
31+
"can you dance?": "I'm not programmed to dance, but I can assist you with your inquiries.",
32+
"what's your favorite movie?": "As a chatbot, I don't have preferences, but I'm here to assist you with your questions.",
33+
"what's your favorite book?": "I don't read, but I'm here to assist you with any questions you have.",
34+
"do you sleep?": "As an artificial intelligence, I don't require sleep, but I'm here to assist you at any time.",
35+
"what's your favorite song?": "I don't have preferences, but I'm here to assist you with your inquiries.",
36+
"can you tell jokes?": "I can try! Why did the computer go to the doctor? Because it had a virus!",
37+
"what's your favorite animal?": "I don't have preferences, but I'm here to assist you with your questions.",
38+
"what's the meaning of love?": "Love can mean different things to different people, but it often involves deep affection and care.",
39+
"what's your favorite sport?": "I don't have preferences, but I'm here to assist you with your inquiries.",
40+
"do you have a sense of humor?": "I can try to be funny! Why was the math book sad? Because it had too many problems!",
41+
"what's the meaning of happiness?": "Happiness is a positive emotional state characterized by feelings of joy, contentment, and satisfaction.",
42+
"can you tell stories?": "I can share information and anecdotes, but I'm not programmed to tell fictional stories.",
43+
"what's the meaning of success?": "Success can mean different things to different people, but it often involves achieving goals and fulfilling aspirations.",
44+
"what's your favorite place?": "As a chatbot, I don't have preferences, but I'm here to assist you with your questions.",
45+
"what's your favorite hobby?": "I don't have hobbies, but I'm here to assist you with your inquiries.",
46+
"can you help me with my homework?": "I can try! What subject are you working on?",
47+
"do you like to travel?": "I don't travel, but I'm here to assist you with your questions.",
48+
"what's the meaning of friendship?": "Friendship is a close and supportive relationship between two or more people.",
49+
"what's the meaning of kindness?": "Kindness is the quality of being friendly, generous, and considerate towards others.",
50+
"what's the meaning of courage?": "Courage is the ability to face challenges, difficulties, and fears with bravery and determination.",
51+
"what's the meaning of determination?": "Determination is the firmness of purpose and the resolve to achieve a goal despite obstacles or setbacks.",
52+
"what's the meaning of resilience?": "Resilience is the ability to adapt and recover from adversity, challenges, or difficult experiences.",
53+
"what's the meaning of empathy?": "Empathy is the ability to understand and share the feelings and perspectives of others.",
54+
"what's the meaning of compassion?": "Compassion is the feeling of deep sympathy and concern for the suffering or misfortune of others.",
55+
"what's the meaning of integrity?": "Integrity is the quality of being honest, ethical, and morally upright in one's thoughts, words, and actions.",
56+
"what's the meaning of gratitude?": "Gratitude is the feeling of thankfulness and appreciation for the kindness, support, or blessings received.",
57+
"what's the meaning of humility?": "Humility is the quality of being modest, humble, and respectful, without arrogance or pride.",
58+
"what's the meaning of patience?": "Patience is the ability to remain calm and composed in the face of delay, frustration, or difficulties.",
59+
"what's the meaning of perseverance?": "Perseverance is the steadfastness and persistence in pursuing goals or objectives despite obstacles or challenges.",
60+
"what's the meaning of forgiveness?": "Forgiveness is the act of letting go of resentment, anger, or bitterness towards someone who has wronged you.",
61+
62+
}
63+
64+
# Function to process user input and generate response
65+
def chatbot_response(input_text):
66+
input_text = input_text.lower()
67+
if input_text in responses:
68+
return responses[input_text]
69+
else:
70+
return "Sorry, I don't understand that."
71+
72+
# Main loop to run the chatbot
73+
while True:
74+
user_input = input("You: ")
75+
response = chatbot_response(user_input)
76+
print("Bot:", response)

‎Naga Sathvik Rapelli/Task 8/task8.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import PyPDF2
2+
import os
3+
4+
def merge_pdfs(input_folder, output_path):
5+
pdf_merger = PyPDF2.PdfWriter()
6+
7+
input_paths = [os.path.join(input_folder, filename) for filename in os.listdir(input_folder) if filename.endswith('.pdf')]
8+
9+
for path in input_paths:
10+
pdf_reader = PyPDF2.PdfReader(path)
11+
for page_num in range(len(pdf_reader.pages)):
12+
page = pdf_reader.pages[page_num]
13+
pdf_merger.add_page(page)
14+
15+
with open(output_path, 'wb') as output_pdf:
16+
pdf_merger.write(output_pdf)
17+
18+
input_folder = 'C:/Users/SATHVIK/OneDrive/Desktop/DESKTOP/APP_POINTS'
19+
output_path = 'C:/Users/SATHVIK/OneDrive/Desktop/merged_pdf.pdf'
20+
21+
merge_pdfs(input_folder, output_path)
22+
print("PDF files merged successfully and saved as 'merged_pdf.pdf' on your desktop.")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /