Python Examples For Beginners

Python: Example For Beginners

EXAMPLE 1: ADD TWO NUMBERS

# This program add two numbers a = 10 b = 20 # add two numbers c = a + b # print the result print("Sum = " . c)

EXAMPLE 2: ADD TWO NUMBERS BY USER INPUT

Output

# take user input and store in variables a = input('Enter the 1st Number: ') b = input('Enter the 2nd Number: ') # add two numbers c = float(a) + float(b) # print the result print("Sum = " . c)

Output

Enter the 1st Number: 10 Enter the 2nd Number: 20 Sum = 30

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
CodingHub

CodingHub

Coding Hub — Learn & Build Your Career