Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions python/OOP/Employees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/python3

class Employees:

def __init__(self, name, department, role, salary, years_employed):

self.name = name
self.department = department
self.role = role
self.salary = salary
self.years_employed = years_employed


def retirement(self):
if self.years_employed >= 20:
return True
else:
False
Binary file added python/OOP/__pycache__/Employees.cpython-310.pyc
Binary file not shown.
12 changes: 12 additions & 0 deletions python/OOP/ouremployees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/python3

from Employees import Employees

employee_1 = Employees("Bob", "Sales", "Director of sales", 10000, 20)

employee_2 = Employees("Linda", "Executive", "CIO", 15000, 10)

print(employee_1.name)
print(employee_1.retirement())


33 changes: 33 additions & 0 deletions python/R-W_on_files/ReadingWriting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/python3

## --------- Reading --------- ##
months = open('months.txt')

# print(months.read())
# print(months.readline()) # read one line
# print(months.readlines()) # read all lines
print(months.read())
# months.seek(0) # return to first line
# print(months.read())

# months.seek(0) # return to first line
# print("Print Using For loop ")
# for month in months:
# print(month)

# months.seek(0) # return to first line
# print("Print Using For loop with strip method")
# for month in months:
# print(month.strip())

months.close()

## --------- Writing --------- ##

# arg 'w' for writing (overwrite), arg 'a' for append
days = open('days.txt', "a")

days.write("Monday")
days.write("\nMonday") # '\n' fo new line

days.close()
3 changes: 3 additions & 0 deletions python/R-W_on_files/days.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Monday
Monday
Monday
12 changes: 12 additions & 0 deletions python/R-W_on_files/months.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Januray
February
March
April
May
June
July
August
September
October
November
December
29 changes: 29 additions & 0 deletions python/input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/python3

name = input("Enter your name: ")
print("Hello, Mr. " + name)

# calculator #

FIRST_NUMBER = float(input("Enter a number: "))
OPERATOR = input("Enter an operator: ")
SECOND_NUMBER = float(input("Enter another number: "))

if OPERATOR == "+":
print(FIRST_NUMBER + SECOND_NUMBER)

elif OPERATOR == "-":
print(FIRST_NUMBER - SECOND_NUMBER)

elif OPERATOR == "*":
print(FIRST_NUMBER * SECOND_NUMBER)

elif OPERATOR == "/":
print(FIRST_NUMBER / SECOND_NUMBER)

elif OPERATOR == "**" or OPERATOR == "^":
print(FIRST_NUMBER ** SECOND_NUMBER)
else:
print("Unknown operator.")


31 changes: 31 additions & 0 deletions python/project/Shoes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/python3

class Shoes:

def __init__(self, name, price):

self.name = name
self.price = float(price)

def budget_check(self, budget):
if not isinstance(budget, (int, float)):
print("Invalid entry. Please enter a number.")
exit()

def change(self, budget):
return (budget - self.price)

def buy(self, budget):

self.budget_check(budget)

if budget >= self.price:
print(f'You can cop some {self.name}')

if budget == self.price:
print("You have enough mony")

else:
print(f'You can buy these shoes and have {self.change(budget)}$ left over')

exit("Goodbye ^_^ ")
Binary file added python/project/__pycache__/Shoes.cpython-310.pyc
Binary file not shown.
13 changes: 13 additions & 0 deletions python/project/purchase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from Shoes import Shoes

low = Shoes('And 1s', 30)
medium = Shoes('Air Force 1s', 120)
high = Shoes('Off Whites', 400)

try:
budget = float(input('What is your budget? '))
except ValueError:
exit('Please enter a number')

for shoes in [high, medium, low]:
shoes.buy(budget)