Skip to content
Closed
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
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

{
"python.linting.enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.mypyArgs": ["--ignore-missing-imports"],
"python.analysis.typeCheckingMode": "basic"
}
21 changes: 21 additions & 0 deletions AYK/class&object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Person:
def __init__(self, name: str, age: int, preferred_operating_system: str):
self.name = name
self.age = age
self.preferred_operating_system = preferred_operating_system

imran = Person("Imran", 22, "Ubuntu")
print(imran.name)

eliza = Person("Eliza", 34, "Arch Linux")
print(eliza.name)


def is_adult (person: Person) ->bool:
return person.age >=18

print(is_adult(imran))

def current_address (address : Person):
return address.location;

30 changes: 30 additions & 0 deletions AYK/typechecking_mypy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
def open_account(balances, name, amount):
balances[name] = amount

def sum_balances(accounts):
total = 0
for name, pence in accounts.items():
print(f"{name} had balance {pence}")
total += pence
return total

def format_pence_as_string(total_pence):
if total_pence < 100:
return f"{total_pence}p"
pounds = int(total_pence / 100)
pence = total_pence % 100
return f"£{pounds}.{pence:02d}"

balances = {
"Sima": 700,
"Linn": 545,
"Georg": 831,
}

open_account(balances,"Tobi", 9.13)
open_account(balances,"Olya", "£7.13")

total_pence = sum_balances(balances)
total_string = format_pence_as_string(total_pence)

print(f"The bank accounts total {total_string}")
5 changes: 5 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
python_version = 3.9.6
warn_return_any = True
warn_unused_configs = True
disallow_untyped_defs = True
ignore_missing_imports = True