mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-30 06:31:46 -08:00
'Refactored by Sourcery'
This commit is contained in:
@@ -35,10 +35,9 @@ class Stock_Market:
|
||||
|
||||
def _generate_day_change(self) -> None:
|
||||
self.changes = []
|
||||
for _ in range(len(self.data)):
|
||||
self.changes.append(
|
||||
round(random.uniform(-5, 5), 2)
|
||||
) # Random % Change b/w -5 and 5
|
||||
self.changes.extend(
|
||||
round(random.uniform(-5, 5), 2) for _ in range(len(self.data))
|
||||
)
|
||||
|
||||
def update_prices(self) -> None:
|
||||
self._generate_day_change()
|
||||
@@ -65,9 +64,9 @@ class Stock_Market:
|
||||
print("\nSTOCK\t\t\t\t\tINITIALS\tPRICE/SHARE($)")
|
||||
for stock, data in self.data.items():
|
||||
if stock != "LBJ":
|
||||
print("{}\t\t\t{}\t\t{}".format(data["Name"], stock, data["Price"]))
|
||||
print(f'{data["Name"]}\t\t\t{stock}\t\t{data["Price"]}')
|
||||
else:
|
||||
print("{}\t\t{}\t\t{}".format(data["Name"], stock, data["Price"]))
|
||||
print(f'{data["Name"]}\t\t{stock}\t\t{data["Price"]}')
|
||||
|
||||
self.print_exchange_average()
|
||||
self.print_assets()
|
||||
|
||||
Reference in New Issue
Block a user