Question: 1 ) i ) Write a Python function calculate ( a , b ) that takes two numbers and returns their sum, difference, product, and

1) i) Write a Python functioncalculate(a, b)that takes two numbers
and returns their sum, difference, product, and quotient. Print the
results.
def calculate(a, b):
# Your code here(5 Marks)
ii) Write a functionis_even(num)that takes an integer and
returnsTrueif the number is even andFalseif it is
odd.
def is_even(num):
# Your code here(2 Marks)
iii) Create a list of 10 integers. Write a functionfilter_even_numbers(lst)that
returns a new list containing only the even numbers from the original
list.
def filter_even_numbers(lst):
# Your code here(3 Marks)
iv) Create a dictionary containing the names and ages of 5 people. Write a
functionget_average_age(person_dict)that calculates and
returns the average age.
def get_average_age(person_dict):
# Your code here(3 Marks)
2. Create a NumPy array of 20 random integers between 1 and 100. Write a
functionarray_statistics(arr)that returns the mean, median,
and standard deviation of the array.
import numpy as np
def array_statistics(arr):
# Your code here(12 Marks)
Ensureyour code runs without errors.
Write comments explaining each part of your code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!