Computer Science, asked by aryanmishra218, 3 months ago

Create a function that takes a list containing more than one sublists as an argument or parameter. Each sublist has 2 elements. The first element is the numerator and the second element is the denominator.
Return the sum of the fractions rounded to the nearest whole number.

Step 1: First, consider the sublist [18, 13]. Divide the first number in this list i.e. 18 by the second number in this list i.e. 13 using list indexing method.

Step 2: Next, consider the second sublist [4, 5]. Divide the first number in this list i.e. 4 by the second number in this list i.e. 5 using list indexing method. There can be more than two sublists. So, perform Step 1 and Step 2 using for loop.

Step 3: Calculate the sum of fractions by adding the results obtained in Step 1 and Step 2.

Step 4: Round off the result to the nearest whole number using the round() function. The syntax of round() function is:

Syntax: round(float_num, num_of_decimals)

where,

float_num is the number to be rounded.
num_of_decimals is the number of decimal places to be considered while rounding. If not specified, number will be rounded to nearest whole number.
For example:

round(2.18,1) will give 2.2
round(2.18) will give 2

Answers

Answered by mamatadhakad8792
7

Answer:

ndcdvtibjrfrgkfig6j th 6k6

Answered by nancychaterjeestar29
0

Answer:

// Bubble sort in Python

def bubbleSort(array):

   

 // loop to access each array element

 for i in range(len(array)):

   // loop to compare array elements

   for j in range(0, len(array) - i - 1):

     // compare two adjacent elements

     // change > to < to sort in descending order

     if array[j] > array[j + 1]:

       // swapping elements if elements

       // are not in the intended order

       temp = array[j]

       array[j] = array[j+1]

       array[j+1] = temp

data = [-2, 45, 0, 11, -9]

bubbleSort(data)

print('Sorted Array in Ascending Order:')

print(data)

Similar questions