From 16f3a6aaedae8739fb86ce8a2ed249d09d3f9082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandru=20Tof=C4=83nel?= Date: Fri, 27 Mar 2026 10:57:51 +0200 Subject: [PATCH] elemente de sintaxa in python --- python/python_syntax/classes_and_methods.py | 22 +++++++++++++++++++++ python/python_syntax/random_module.py | 16 +++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 python/python_syntax/classes_and_methods.py create mode 100644 python/python_syntax/random_module.py diff --git a/python/python_syntax/classes_and_methods.py b/python/python_syntax/classes_and_methods.py new file mode 100644 index 0000000..11d3319 --- /dev/null +++ b/python/python_syntax/classes_and_methods.py @@ -0,0 +1,22 @@ +class BankAccount: + def __init__(self, first_name, last_name, account_id, account_type, pin, balance): + self.first_name = first_name + self.last_name = last_name + self.account_id = account_id + self.account_type = account_type + self.pin = pin + self.balance = balance + + def deposit(self, amount): + self.balance += amount + return self.balance + def withdraw(self, amount): + self.balance -= amount + return self.balance + def display_balance(self): + print(self.balance) + +larry = BankAccount("Larry", "Smith" ,1, "debit", 1234, 0.) +larry.deposit(96) +larry.withdraw(25) +larry.display_balance() diff --git a/python/python_syntax/random_module.py b/python/python_syntax/random_module.py new file mode 100644 index 0000000..7a72477 --- /dev/null +++ b/python/python_syntax/random_module.py @@ -0,0 +1,16 @@ +import random + +symbols = ['🍒', '🍇', '🍉', '7️⃣'] +results = random.choices(symbols, k=3) +print(results[0] + "|" + results[1] + "|" + results[2]) +sevens = False +for i in range(0, len(results)-1): + if results[i] == '7️⃣' and results[i+1] == '7️⃣': + sevens = True and sevens + else: + sevens = False + +if sevens == True: + print("Jackpot!") +else: + print("Thanks for playing!")