0% found this document useful (0 votes)
13 views5 pages

Big Data

The document contains practice assignments for an introduction to big data course, featuring Python programs that perform various tasks. These include calculating average marks for five courses, performing arithmetic operations on ten integers, calculating the number of seconds in a day, and converting currency based on user input. Each program is accompanied by its respective solution code.
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)
13 views5 pages

Big Data

The document contains practice assignments for an introduction to big data course, featuring Python programs that perform various tasks. These include calculating average marks for five courses, performing arithmetic operations on ten integers, calculating the number of seconds in a day, and converting currency based on user input. Each program is accompanied by its respective solution code.
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/ 5

NSENGUMUREMYI Alain Richard

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

for course in courses:


mark = float(input(f"Enter marks for {course}: "))
marks.append(mark)
print(f"{course}: {mark}")

average = sum(marks) / len(marks)


print(f"Average Marks: {average:.2f}")

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

4. a program that converts a sum of money to a


different currency. The amount of money to be converted and the exchange
rate are entered by the user. The program should have separate functions for:
• obtaining the sum of money from the user;
• obtaining the exchange rate from the user;
• making the conversion;
• displaying the result.
------------------------------------------------------------------------------------------------------------------------
SOLUTION
def get_amount():
return float(input("Enter the amount of money: "))

def get_exchange_rate():
return float(input("Enter the exchange rate: "))

def convert_currency(amount, rate):


return amount * 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()

You might also like