Skip to content

Commit 40e3855

Browse files
authored
Add files via upload
1 parent 757c296 commit 40e3855

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

BeautifulSoup.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
URL = "https://realpython.github.io/fake-jobs/"
5+
page = requests.get(URL)
6+
7+
#print(page.text)
8+
9+
soup = BeautifulSoup(page.content, "html.parser")
10+
results = soup.find(id="ResultsContainer")
11+
#print(results.prettify())
12+
13+
job_elements = results.find_all("div", class_="card-content")
14+
15+
# for job_element in job_elements:
16+
# print(job_element, end="\n" * 2)
17+
18+
# for job_element in job_elements:
19+
# title_element = job_element.find("h2", class_="title")
20+
# company_element = job_element.find("h3", class_="company")
21+
# location_element = job_element.find("p", class_="location")
22+
# print(title_element)
23+
# print(company_element)
24+
# print(location_element)
25+
# print()
26+
27+
for job_element in job_elements:
28+
title_element = job_element.find("h2", class_="title")
29+
company_element = job_element.find("h3", class_="company")
30+
location_element = job_element.find("p", class_="location")
31+
print(title_element.text.strip())
32+
print(company_element.text.strip())
33+
print(location_element.text.strip())
34+
print()
35+
36+
python_jobs = results.find_all("h2", string="Python")
37+
38+
print(python_jobs)

budget_calc.py

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import os
2+
import sys
3+
4+
class Application():
5+
def __init__(self):
6+
self.income = 0
7+
self.expenses = 0
8+
self.expense_list = []
9+
self.expense_name = []
10+
self.income_name = []
11+
self.income_list = []
12+
self.prompt_income()
13+
14+
def income_ask(self):
15+
add_income = input('Add income? [y/n]: ')
16+
return add_income
17+
18+
def income_sum(self):
19+
self.income = sum(self.income_list)
20+
21+
def expense_ask(self):
22+
add_expense = input('Add expense? [y/n]: ')
23+
return add_expense
24+
25+
def expense_sum(self):
26+
self.expenses = sum(self.expense_list)
27+
28+
def income_check(self):
29+
if not self.income_list:
30+
print('Please enter atleast one source of income. ')
31+
self.prompt_income()
32+
else:
33+
return
34+
35+
def expense_check(self):
36+
if not self.expense_list:
37+
print('Please enter atleast one expense. ')
38+
self.prompt_expense()
39+
else:
40+
return
41+
42+
def prompt_income(self):
43+
x = False
44+
while not x:
45+
result = self.income_ask()
46+
if result == 'y':
47+
income_input = int(input('Enter source of income. [Numbers Only]: '))
48+
self.income_list.append(income_input)
49+
income_name = input('Enter income name. [Name Only]: ')
50+
self.income_name.append(income_name)
51+
else:
52+
self.income_check()
53+
x = True
54+
self.income_sum()
55+
name = [name for name in self.income_name]
56+
income = [income for income in self.income_list]
57+
incomedict = dict(zip(name, income))
58+
for k in incomedict:
59+
print(k + ': ', '$' + str(incomedict[k]))
60+
print('Total user income: ', '$' + str(self.income))
61+
self.prompt_expense()
62+
63+
def prompt_expense(self):
64+
x = False
65+
while not x:
66+
result = self.expense_ask()
67+
if result == 'y':
68+
expense_input = int(input('Enter expense amount. [Numbers Only]: '))
69+
self.expense_list.append(expense_input)
70+
expense_name = input('Enter expense name. [Name Only]: ')
71+
self.expense_name.append(expense_name)
72+
else:
73+
self.expense_check()
74+
x = True
75+
self.expense_sum()
76+
name = [name for name in self.expense_name]
77+
expense = [income for income in self.expense_list]
78+
expensedict = dict(zip(name, expense))
79+
for k in expensedict:
80+
print(k + ': ', '$' + str(expensedict[k]))
81+
print('Total user expenses: ', '$' + str(self.expenses))
82+
self.uservalue()
83+
84+
def uservalue(self):
85+
valoutput = self.income - self.expenses
86+
if valoutput < 0:
87+
print('You are in the negative, you have a deficit of ' + '$' + str(valoutput))
88+
if valoutput == 0:
89+
print('You have broken even, you are spending exactly as much as you make.')
90+
if valoutput > 0:
91+
print('You are in the positive, you have a surplus of ' + '$' + str(valoutput))
92+
another = input('Would you like to run another analysis? [y/n]: ')
93+
if another == 'y':
94+
self.reset_program()
95+
else:
96+
self.close_program()
97+
98+
def reset_program(self):
99+
self.income = 0
100+
self.expenses = 0
101+
del self.expense_list[0:]
102+
del self.expense_name[0:]
103+
del self.income_name[0:]
104+
del self.income_list[0:]
105+
self.prompt_income()
106+
107+
def close_program(self):
108+
print('Exiting Program.')
109+
sys.exit(0)
110+
111+
if __name__ == '__main__':
112+
Application()

0 commit comments

Comments
 (0)