0% found this document useful (0 votes)
8 views3 pages

ECE054 Lab1

The document is a Jupyter notebook containing Python code examples demonstrating basic programming concepts such as variable assignment, arithmetic operations, conditional statements, and functions from the math module. It includes interactive problems related to population calculation, item packaging, and salad preparation. The notebook is designed for educational purposes, likely for a lab session at Amrita Vishwa Vidyapeetham.

Uploaded by

cocifis518
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

ECE054 Lab1

The document is a Jupyter notebook containing Python code examples demonstrating basic programming concepts such as variable assignment, arithmetic operations, conditional statements, and functions from the math module. It includes interactive problems related to population calculation, item packaging, and salad preparation. The notebook is designed for educational purposes, likely for a lab session at Amrita Vishwa Vidyapeetham.

Uploaded by

cocifis518
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

28/10/2023, 14:37 ECE054-Lab1.

ipynb - Colaboratory

print(" Amrita Vishwa Vidyapeetham")

Amrita Vishwa Vidyapeetham

print(" Hello, World")

Hello, World

x = 5
y = " Amrita"
print(x)
print(y)

5
Amrita

x,y,z = " Orange", " Banana"," Cherry"


print(x)
print(y)
print(z)

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))

Absolute value of -20 is 20


Absolute value of -30.33 is 30.33

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 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

x = int(input(" Enter the number of people in the town :"))


y = int(input(" Enter the number of people who left the town :"))
z = int(input(" Enter the number of people immigrated to the town :"))
p = (x-y)+z
print("The current population of the town is", p, " million")

Enter the number of people in the town : 3


Enter the number of people who left the town : 1
Enter the number of people immigrated to the town : 2
The current population of the town is 4 million

2) Polybags

a = int(input("Enter the number of items he bought :"))


b = a//10
c = a%10
if c != 0 and c<10:
d = b+1
elif c == 0:
d = b

print(" The total number of bags he need is", d)

Enter the number of items he bought : 121


The total number of bags he need is 13

3) Fruitchaat

print(" Welcome to SALAD STAND")


a = int(input("Enter number of apples="))
b = int(input("Enter number of bananas="))
c = b//2
if c <= a:
print("No: of salad =",c)
else:
print("No: of salads =",a)

Welcome to SALAD STAND


Enter number of apples=4
Enter number of bananas=3
No: of salad = 1

https://colab.research.google.com/drive/1HJF32xFrgti_pFCPFhvRqxjpIurG4sO2#printMode=true 3/3

You might also like