ECE054 Lab1
ECE054 Lab1
ipynb - Colaboratory
Hello, World
x = 5
y = " Amrita"
print(x)
print(y)
5
Amrita
account_circle Orange
Banana
Cherry
x = y = z = "Orange"
print(x)
print(y)
print(z)
Orange
Orange
Orange
x = 10
y = 5
z = x+y
print(z)
print(" x+y =", x+y)
15
x+y = 15
x = 10
y = 5
z = x-y
print(z)
print(" x-y =", x-y)
5
x-y = 5
x = 10
y = 5
z = x*y
print(z)
print(" x*y =", x*y)
50
x*y = 50
x = 10
y = 5
print(" x/y =", x/y)
print(" x//y =", x//y)
x/y = 2.0
x//y = 2
x = 103
y = 5
print("x % y =", x % y)
x = 100
y = 5
print(" x % y =", x % y)
https://colab.research.google.com/drive/1HJF32xFrgti_pFCPFhvRqxjpIurG4sO2#printMode=true 1/3
28/10/2023, 14:37 ECE054-Lab1.ipynb - Colaboratory
x % y = 3
x % y = 0
x = 15
y = 6
print(" x ** y =", x ** y)
x ** y = 11390625
import math
x = 4.5467
print(math.ceil(x))
x = 4.1467
print(math.ceil(x))
x = 4
print(math.ceil(x))
x = -4.5467
print(math.ceil(x))
5
5
4
-4
import math
my_int = 4.5467
print(math.floor(my_int))
my_int = 4.9467
print(math.floor(my_int))
my_int = 4
print(math.floor(my_int))
my_int = -4.5467
print(math.floor(my_int))
4
4
4
-5
integer = -20
print("Absolute value of -20 is", abs(integer))
floating = -30.33
print("Absolute value of -30.33 is", abs(floating))
a = 33
b = 200
if b>a :
print(" b is greater than a ")
b is greater than a
a = 33
b = 33
if b>a :
print(" b is greater than a ")
elif a == b:
print(" a and b are equal")
a = 200
b = 33
if b>a :
print(" b is greater than a ")
elif a == b:
https://colab.research.google.com/drive/1HJF32xFrgti_pFCPFhvRqxjpIurG4sO2#printMode=true 2/3
28/10/2023, 14:37 ECE054-Lab1.ipynb - Colaboratory
print(" a and b are equal")
else:
print(" a is greater than b")
a is greater than b
PROBLEMS
1) Final Population
2) Polybags
3) Fruitchaat
https://colab.research.google.com/drive/1HJF32xFrgti_pFCPFhvRqxjpIurG4sO2#printMode=true 3/3