Skip to content

01‐Basics‐Add.py

SunilOS edited this page Sep 11, 2024 · 1 revision

Here's a breakdown and explanation of the Python program:

a = 10
b = 20
c = 0
c = a + b
print("Add = ", c)

Explanation:

  1. Variable Assignment:

    • a = 10: The variable a is assigned the value 10.
    • b = 20: The variable b is assigned the value 20.
    • c = 0: Initially, the variable c is assigned the value 0.
  2. Addition Operation:

    • c = a + b: This line performs the addition of the variables a and b, which is 10 + 20. The result, 30, is then assigned to the variable c.
  3. Output:

    • print("Add = ", c): This line prints the message "Add = " followed by the value of c, which is 30.

Output:

The output of this program will be:

Add =  30

Key Concepts:

  • Variable assignment: Variables store data values. Here, a, b, and c are integer variables.
  • Operators: The + operator is used to add the values of a and b.
  • Print statement: The print() function outputs text to the console.

This is a basic Python program demonstrating how to assign variables, perform arithmetic operations, and print the result to the console.

Clone this wiki locally