Python ödevi nasıl yapılabilir?

hüseyin havadar

Hectopat
Katılım
22 Haziran 2019
Mesajlar
43
Python ödevi hakkında yardıma ihtiyacım var. Kod yazma hakkında bir şey bilmiyorum ve bölümümle alakalı olmadığı için yapabilen olursa çok sevinirim. Tek adımdan oluşan basit bir ödev.

In this task you will create the Python file on VS Code with named “Name_Surname_PythonTask02.py” and write your Python script and finally upload your created file on lms. You are practice about following concepts: Conditional execution, comparison operators, boolean expressions, scope of the block, ıf, else and Elif statement, nested decisions statement, and also previous weeks topics like variables, types, assignment, expression, Print(), Type() and Input() methods. Note: Notice that you are expected to submit a single python file. Make sure that you include your code for all four steps in a single .py file. 1. Write python script that will calculate the total amount of money a customer should pay at a grocery store according to the prices given as follows: 1 kg of apples is 14 TL, 1 kg of bananas is 44 TL, 1 kg of strawberries is 60 TL and 1 kg of oranges is 20 TL. If the customer wants to buy more than 10 kilos of each item, able to get the following discounts.
• If the apple is bought more than 10 kilograms, the kilogram price will be 10 TL.
• If the banana is bought more than 5 kilograms, the kilogram price will be 42 TL.
• If the strawberry is bought more than 5 kilograms, the kilogram price will be 50 TL.
• If the orange is bought more than 10 kilograms, the kilogram price will be 15 TL.

After asking for how much kilograms of each fruit the customer wants to buy, calculate the total amount of money that customer should pay. Please check the sample output. Note: Customers can buy fruits in decimal numbers.
sample output:
welcome! Please enter the weight values of the items you want to buy?
Apple kg: 9
Banana kg: 7
Strawberry kg: 3
Orange kg: 12
You should pay 780 TL
 
ChatGPT'ye yaptırdım.

Python:
# Welcome message
print("Welcome! Please enter the weight values of the items you want to buy:")

# Get fruit weights from user
apple_kg = float(input("Apple kg: "))
banana_kg = float(input("Banana kg: "))
strawberry_kg = float(input("Strawberry kg: "))
orange_kg = float(input("Orange kg: "))

# Set fruit prices
apple_price = 14
banana_price = 44
strawberry_price = 60
orange_price = 20

# Check if discounts apply and set discounted prices
if apple_kg > 10:
    apple_price = 10
if banana_kg > 5:
    banana_price = 42
if strawberry_kg > 5:
    strawberry_price = 50
if orange_kg > 10:
    orange_price = 15

# Calculate total cost
total_cost = apple_kg * apple_price + banana_kg * banana_price + strawberry_kg * strawberry_price + orange_kg * orange_price

# Print total cost
print(f"You should pay {total_cost} TL")


Screenshot_1.png
 
GPT-3 Chat yapay zekasını kullanarak bunu yazdırabilirsin. Basamak basamak neler istediğini söyle. İstediğin kodu yazdıracaktır.

ChatGPT'ye yaptırdım.

Python:
# Welcome message
print("Welcome! Please enter the weight values of the items you want to buy:")

# Get fruit weights from user
apple_kg = float(input("Apple kg: "))
banana_kg = float(input("Banana kg: "))
strawberry_kg = float(input("Strawberry kg: "))
orange_kg = float(input("Orange kg: "))

# Set fruit prices
apple_price = 14
banana_price = 44
strawberry_price = 60
orange_price = 20

# Check if discounts apply and set discounted prices
if apple_kg > 10:
    apple_price = 10
if banana_kg > 5:
    banana_price = 42
if strawberry_kg > 5:
    strawberry_price = 50
if orange_kg > 10:
    orange_price = 15

# Calculate total cost
total_cost = apple_kg * apple_price + banana_kg * banana_price + strawberry_kg * strawberry_price + orange_kg * orange_price

# Print total cost
print(f"You should pay {total_cost} TL")


Eki Görüntüle 1613454
Ben mesajı yazarken siz yaptırmışsınız.
 
ChatGPT'ye yaptırdım.

Python:
# Welcome message
print("Welcome! Please enter the weight values of the items you want to buy:")

# Get fruit weights from user
apple_kg = float(input("Apple kg: "))
banana_kg = float(input("Banana kg: "))
strawberry_kg = float(input("Strawberry kg: "))
orange_kg = float(input("Orange kg: "))

# Set fruit prices
apple_price = 14
banana_price = 44
strawberry_price = 60
orange_price = 20

# Check if discounts apply and set discounted prices
if apple_kg > 10:
    apple_price = 10
if banana_kg > 5:
    banana_price = 42
if strawberry_kg > 5:
    strawberry_price = 50
if orange_kg > 10:
    orange_price = 15

# Calculate total cost
total_cost = apple_kg * apple_price + banana_kg * banana_price + strawberry_kg * strawberry_price + orange_kg * orange_price

# Print total cost
print(f"You should pay {total_cost} TL")


Eki Görüntüle 1613454
yok artık:) nasıl oluyor bu kadar yapay zeka?
 
ChatGPT'ye yaptırdım.

Python:
# Welcome message.
print("Welcome! Please enter the weight values of the items you want to buy:")

# Get fruit weights from user.
apple_kg = float(input("Apple kg: "))
banana_kg = float(input("Banana kg: "))
strawberry_kg = float(input("Strawberry kg: "))
orange_kg = float(input("Orange kg: "))

# Set fruit prices.
apple_price = 14.
banana_price = 44.
strawberry_price = 60.
orange_price = 20.

# Check if discounts apply and set discounted prices.
if apple_kg > 10:
 apple_price = 10.
if banana_kg > 5:
 banana_price = 42.
if strawberry_kg > 5:
 strawberry_price = 50.
if orange_kg > 10:
 orange_price = 15.

# Calculate total cost.
total_cost = apple_kg * apple_price + banana_kg * banana_price + strawberry_kg * strawberry_price + orange_kg * orange_price.

# Print total cost.
print(f"You should pay {total_cost} TL")

Eki Görüntüle 1613454

Teşekkürler. Bu siteyi öğrendiğim iyi oldu.
 

Yeni konular

Geri
Yukarı