Code Addition Code
Code Addition Code
print('Hello, world!')
_______________________________________________________
num1 = 1.5
num2 = 6.3
Step-by-Step Explanation
1. Comment Line
# This program adds two numbers
• This is a comment in Python.
• Comments start with # and are ignored by the Python interpreter.
• They are useful for explaining what the code does.
2. Declaring Variables
num1 = 1.5
num2 = 6.3
• num1 and num2 are floating-point numbers (decimal numbers).
• 1.5 and 6.3 are stored in these variables.
Formatted Output:
The sum of 1.5 and 6.3 is 7.8
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
Step-by-Step Explanation
1 Taking User Input
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
• The input() function is used to take input from the user.
• The text inside input('...') is displayed as a prompt.
• Whatever the user enters is stored as a string in num1 and num2.
Calculation:
sum = 5.5 + 4.5
sum = 10.0
Example Output:
The sum of 5.5 and 4.5 is 10.0