SKILLING Experiments: EX (1.a) Solution

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

SKILLING Experiments

1. SHYAM is working on a project based on performing arithmetic and logical operations


with numbers. So help him out by writing a Python program that considers ‘a’ and ‘b’ as
input and gives the result of all arithmetic & logical operations as output .Use different
modules for every operation.

2. write a python code to generate a Pascal’s triangle by taking a number n as an input and
generate Pascal triangle with n+1 lines as output.

EX (1.a) solution :

# Examples of Arithmetic Operator


a = 9
b = 4
 
# Addition of numbers
add = a + b
 
# Subtraction of numbers
sub = a - b
 
# Multiplication of number
mul = a * b
 
# Division(float) of number
div1 = a / b
 
# Division(floor) of number
div2 = a // b
 
# Modulo of both number
mod = a % b
 
# Power
p = a ** b
 
# print results
print(add)
print(sub)
print(mul)
print(div1)
print(div2)
print(mod)
print(p)
EX.(1b) solution:

# Python program to demonstrate


# logical or operator
  
a = 10
b = -10
c = 0
  
if a > 0 or b > 0:
    print("Either of the number is greater than
0")
else:
    print("No number is greater than 0")
  
if b > 0 or c > 0:
    print("Either of the number is greater than
0")
else:
    print("No number is greater than 0")

Output:
Either of the number is greater than 0
No number is greater than 0

You might also like