Big Data
Big Data
22956
INTRODUCTION TO BIG DATA
Practice Assignment-I
1. a program to read the marks of Five courses, output course and marks on separate lines and find the
average of them.
SOLUTION
------------------------------------------------------------------------------------------------------------------------
def calculate_average():
marks = []
courses = ['Math', 'Science', 'History', 'English', 'Art']
calculate_average()
2. a program to read 10 integers and perform arithmetic operations on
them
(addition, subtraction, multiplication and division).
Output:
Addition of Number:
Subtraction of Numbers:
Multiplication of Numbers:
------------------------------------------------------------------------------------------------------------------------
SOLUTION
def arithmetic_operations():
numbers = []
print("Enter 10 integers:")
for _ in range(10):
number = int(input())
numbers.append(number)
addition = sum(numbers)
subtraction = numbers[0]
for num in numbers[1:]:
subtraction -= num
multiplication = 1
for num in numbers:
multiplication *= num
division = numbers[0]
for num in numbers[1:]:
if num != 0:
division /= num
else:
division = "Undefined (division by zero)"
break
print(f"Addition of Numbers: {addition}")
print(f"Subtraction of Numbers: {subtraction}")
print(f"Multiplication of Numbers: {multiplication}")
print(f"Division of Numbers: {division}")
arithmetic_operations()
3. a program that calculates the number of seconds in a day.
------------------------------------------------------------------------------------------------------------------------
SOLUTION
def seconds_in_a_day():
seconds = 24 * 60 * 60 # 24 hours, 60 minutes, 60 seconds
print(f"Number of seconds in a day: {seconds}")
seconds_in_a_day()
def get_exchange_rate():
return float(input("Enter the exchange rate: "))
def display_result(converted_amount):
print(f"Converted Amount: {converted_amount:.2f}")
def currency_converter():
amount = get_amount()
rate = get_exchange_rate()
converted_amount = convert_currency(amount, rate)
display_result(converted_amount)
currency_converter()