Problem Statement:
Given a list of integers (both positive and negative) find the largest continuous sum.
e.g.
Input:
list1 = [1, 2, -1, 3, 4, 10, 10, -10, -1]
Output: 29
Solution:
Problem Statement:
Given a list of integers (both positive and negative) find the largest continuous sum.
e.g.
Input:
list1 = [1, 2, -1, 3, 4, 10, 10, -10, -1]
Output: 29
Solution:
Problem Statement: Consider array/list of non-negative integers. The second array/list is formed by shuffling the elements of the first array/list and deleting a random element. Given these two arrays/lists, find which element is missing in second array.
e.g.
list1 = [1, 2, 3, 4, 5, 6]
list2 = [2, 5, 4, 6, 3]
here missing element is 1.
Solution:
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
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
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
Dielectric constant Metals have infinite Dielectric constant As usually metals permittivity is very large than of free space hence its Die...