+ 2
Where did mess up....
I'm not getting what it wants me to do.. # Asks the user to enter the savings savings = input("Enter your savings:") # Convert the user input into a float value and update the variable savings = float(input("Enter your savings:")) # Savings grow after 1 year at a 5% annual interest rate balance = savings * 1.05 # Convert the balance into a string and update the variable balance = str(balance) # Concatenate the 2 strings to produce a message message = "Amount in 1 year: " + balance # Display the message print(message) Pls help..
13 Antwoorden
+ 4
In the second line of code, you need to write savings=float(savings) instead of savings=float(input()).
+ 6
Did the task come with the text "enter your savings", or did you add that?
Look closely at your 2nd line of coding (ignoring comments). Do you need input 2x? *hint: maybe that's the line to change
+ 3
Thanks..
I was writing it 2 times..
This is the correct code according to the question
# Asks the user to enter the savings
savings = input()
# Convert the user input into a float value and update the variable
savings = float(savings)
# Savings grow after 1 year at a 5% annual interest rate
balance = savings * 1.05
# Convert the balance into a string and update the variable
balance = str(balance)
# Concatenate the 2 strings to produce a message
message = "Amount in 1 year: " + balance
# Display the message
print(message)
+ 3
Lucky Zxy
What also could be an helpful feature, which is in my personal opinion much too less used in Python, is to work with the `->`-operator to strictly type Pythonic values.
For example like:
```python
def get_float(prompt: str) -> float:
"""
Prompt the user until they enter a valid float.
"""
while True:
entry = input(prompt)
try:
value = float(entry)
return value
except ValueError:
print(f"❗️ '{entry}' is not a valid number. Please try again.")
```
+ 2
Aditya Aditya
💁 (sorry for eventual incorrect translation):
```python
# उपयोगकर्ता से दो संख्याएँ इनपुट लें
num1 = float(input("पहली संख्या दर्ज करें: "))
num2 = float(input("दूसरी संख्या दर्ज करें: "))
# गुणनफल निकालें
product = num1 * num2
# परिणाम दिखाएं
print("गुणनफल है:", product)
```
+ 1
Aditya Aditya , we are here to help each other learn together. Please specify your problem or question so that we can solve it together.
+ 1
ANURAG SHAHIB , thank you for sharing your knowledge!
I would like to tell you that even though one liners are short yet precise and effective, they are difficult to understand at first glance especially if you are a beginner.
However, this was a comparitively simple and easy one.
Lucky Zxy , kindly let us know if that helped. And if you have further questions, feel free to ask!
0
# Ask the user to enter savings (only once) and convert to float
savings = float(input("Enter your savings: "))
# Calculate balance after 1 year with 5% interest
balance = savings * 1.05
# Round to 2 decimal places (if needed for currency)
balance = round(balance, 2)
# Convert to string for concatenation
balance_str = str(balance)
# Construct and print the message
message = "Amount in 1 year: " + balance_str
print(message)
0
Hi I am new please help me
0
Hello python me kaise 2 no. Ka product kaise kar
0
Reply please dena
0
Raj Verma , if you want to output the product of two input numbers, you may use the multiplication (*) operator.
n1 = float(input())
n2 = float(input())
print(n1*n2)
Test case:
n1 = 3
n2 = 13
Output: 39