Friday, April 2, 2021
555 Timer as Monostable Multivibrator
Saturday, March 20, 2021
Python: Addition, Subtraction, Multiplication and Division using function
Program:
#Addition function
def addition(a,b):
c=a+b
print("Addition= ",c)
print("Enter two numbers")
#Subtraction function
def subtraction(a,b):
c=a-b
print("Subtraction= ",c)
#Multiplication function
def multiplication(a,b):
c=a*b
print("Multiplication= ",c)
#Division function
def division(a,b):
c=a/b
print("Division= ",c)
a=float(input())
b=float(input())
addition(a,b)
subtraction(a,b)
multiplication(a,b)
division(a,b)
Output:
Enter two numbers
8
4
Addition= 12.0
Subtraction= 4.0
Multiplication= 32.0
Division= 2.0
Python: Addition of two numbers using function
Below is a simple addition program demonstrated using function addition. This program shows you how to use function in Python
def addition(a,b): #This is funtion definitation
c=a+b
print("Addition = {}".format(c))
print("Enter two numbers to be added")
a=int(input())
b=int(input())
addition(a,b) #call the function addition() by passing two numbers a & b
Text in green are comments
Output:
Enter two numbers to be added
341
12
Addition = 353
Program for addition of two number using Python
This is a simple program for addition of two numbers using Python.
Program takes two numbers as input from the user and prints the sum as output.
#Simple Program for addition of two number without using function
print("Enter two numbers to be added")
#int can have numbers in the range -2147483648 through 2147483647
a=int(input()) #takes first number as input from user
b=int(input()) #takes second number as input from user
c=a+b #adds two numbers a & b and saves to c
print("Addition of numbers {} and {} is {}".format(a,b,c))
Text in green color shows the comments
Output:
Enter two numbers to be added
123
123
Addition of numbers 123 and 123 is 246
Saturday, January 30, 2021
Upstox Free Demat and Trading account opening
Saturday, July 4, 2020
Voltage Divider Circuit Simulation using Proteus Circuit design software
Cookie used by Blog
Some useful parameters
Dielectric constant Metals have infinite Dielectric constant As usually metals permittivity is very large than of free space hence its Die...
-
Building Logic gates using Op-amp 1.AND gate using op-amp:circuit diagram Check out the above circuit At inverting input of op...
-
System Design Technologies There are four design technologies: Fixed-Function IC Full Custom ASIC Semi Custom ASIC PLD Technology Fixed-Fun...