0% found this document useful (0 votes)
51 views2 pages

Example of List in Python

The document provides examples of representing bank account transactions as a list containing dictionaries or tuples. Each dictionary/tuple includes details of a transaction such as date, amount, type (deposit or withdrawal), and description. The list stores multiple transactions and allows viewing them chronologically or filtering by type for budgeting and tracking purposes. Loops are used to iterate through the lists and print out details of each transaction.

Uploaded by

yashu.sachdeva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views2 pages

Example of List in Python

The document provides examples of representing bank account transactions as a list containing dictionaries or tuples. Each dictionary/tuple includes details of a transaction such as date, amount, type (deposit or withdrawal), and description. The list stores multiple transactions and allows viewing them chronologically or filtering by type for budgeting and tracking purposes. Loops are used to iterate through the lists and print out details of each transaction.

Uploaded by

yashu.sachdeva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#Let's create an example of a list representing bank account transactions.

Each
transaction can include details such as the date, description, amount, and
transaction type. Here's a sample list with fictional data:

# In this example:

# Each transaction is represented as a dictionary with keys like "date,"


"description," "amount," and "transaction_type."
# The bank_transactions list contains multiple transactions.
# Positive amounts represent deposits, and negative amounts represent withdrawals.
# The loop at the end prints out the details of each transaction.

# A list can store the history of your bank account transactions, including the
date, amount, description, and category (debit or credit). This allows you to see
your transactions in chronological order and filter them by category for easier
budgeting and tracking.

bank_transactions = [
{"date": "2024-03-01", "description": "Salary Deposit", "amount": 5000.00,
"transaction_type": "Deposit"},
{"date": "2024-03-05", "description": "Grocery Store", "amount": -150.00,
"transaction_type": "Withdrawal"},
{"date": "2024-03-10", "description": "Utility Bill Payment", "amount": -80.00,
"transaction_type": "Withdrawal"},
{"date": "2024-03-15", "description": "Dinner with Friends", "amount": -40.00,
"transaction_type": "Withdrawal"},
{"date": "2024-03-20", "description": "Online Purchase", "amount": -120.00,
"transaction_type": "Withdrawal"},
{"date": "2024-03-25", "description": "Investment Dividends", "amount": 100.00,
"transaction_type": "Deposit"},
]

# Display the transactions


for transaction in bank_transactions:
print(f"Date: {transaction['date']}, Description: {transaction['description']},
Amount: {transaction['amount']}, Type: {transaction['transaction_type']}")

# List of Tuples

# You've provided a list of tuples representing bank account transactions. It seems


like each tuple includes the transaction date, amount, transaction type, and a
brief description. This format is still a valid and concise representation of bank
transactions. Here's the updated list:

# In this example, each tuple has four elements: date, amount, transaction type,
and description. The loop at the end prints out the details of each transaction
using unpacking to access individual elements of the tuple.

bank_transactions = [
("2024-03-08", 100.00, "Deposit", "Salary"),
("2024-03-06", -25.00, "Withdrawal", "Coffee"),
("2024-03-01", 50.00, "Deposit", "Allowance"),
("2024-02-29", -150.00, "Withdrawal", "Rent"),
]
# Display the transactions
for transaction in bank_transactions:
date, amount, transaction_type, description = transaction
print(f"Date: {date}, Amount: {amount}, Type: {transaction_type}, Description:
{description}")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy