Skip to content

Commit d9878b3

Browse files
committed
exercise solutions for python numbers
1 parent 93f52c4 commit d9878b3

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

number in python/exercise1.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#You have a football field that is
2+
# 92 meter long and 48.8 meter wide.
3+
# Find out total area using python and print it.
4+
5+
width=48.8
6+
height=92
7+
area=width*height
8+
9+
print("Total area of the football field is: ",round(area,2))

number in python/exercise2.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#You bought 9 packets of potato chips from a store.
2+
# Each packet costs 1.49 dollar and
3+
# you gave shopkeeper 20 dollar.
4+
# Find out using python, how many dollars is the shopkeeper going to give you back?
5+
6+
potato_packet_count=9
7+
price_per_packet=1.49
8+
9+
total_cost=9*1.49
10+
11+
change=20-total_cost
12+
13+
print("The change is: ",change)

number in python/exercise3.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#You want to replace tiles in your bathroom
2+
# which is exactly square and 5.5 feet is its length.
3+
# If tiles cost 500 rs per square feet,
4+
# how much will be the total cost to replace all tiles.
5+
# Calculate and print the cost using python
6+
# (Hint: Use power operator ** to find area of a square)
7+
8+
9+
area_of_the_bathroom=5.5**2
10+
tile_cost_per_sqfeet=500
11+
12+
print("Total cost to replace all tiles: ",area_of_the_bathroom*tile_cost_per_sqfeet)
13+

number in python/exercise4.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Print binary representation of number 17
2+
3+
number=17
4+
5+
print("Binary number of 17 is: ",format(number,'b'))

0 commit comments

Comments
 (0)