بخشی از مجموعه

Several example codes

~1 دقیقه مطالعه • بروزرسانی ۹ مهر ۱۴۰۴

Program Overview

This Python program reads the number of items and the price of each item from the user, then calculates the total sales amount.
The calculation is based on the formula:
Sales Amount = Quantity × Unit Price


Python Code:


# Read inputs from user
count = int(input("Enter the number of items: "))
price = float(input("Enter the price per item: "))

# Calculate total sales amount
total = count * price

# Display result
print("\n--- Result ---")
print(f"Total sales amount: {total} units")

Sample Output:


Enter the number of items: 5  
Enter the price per item: 12000  

--- Result ---  
Total sales amount: 60000 units

Step-by-Step Explanation:

- The user provides two inputs: item count (integer) and unit price (float)
- The program multiplies these values to calculate the total
- The result is displayed clearly and numerically


نوشته و پژوهش شده توسط دکتر شاهین صیامی