# Average Function | hackerrank certification problem solution

** Average Function | hackerrank certification Problem:-**

Average Function | hackerrank certification problem solution

Implement a function that:

1. Is named avg

2. Takes a variable number of integer arguments; it is guaranteed that at least one argument will be passed

1. Is named avg

2. Takes a variable number of integer arguments; it is guaranteed that at least one argument will be passed

3. Returns the average value of the passed arguments as a float

The implementation will be tested by a provided code stub on several input files. Each input file contains one line with space-separated arguments for the function. The function will be called with those arguments, and the returned result will be printed to the output with exactly 2 decimal places.

The implementation will be tested by a provided code stub on several input files. Each input file contains one line with space-separated arguments for the function. The function will be called with those arguments, and the returned result will be printed to the output with exactly 2 decimal places.

**Example**

3 arguments are read and passed to the function: 1, 2, and 3.

The average is calculated to be (1+2+3)/3 =2.00.

This is then returned as a float to be printed.

**Average Function | hackerrank certification problem solution:-**

import math import os import random import re import sys def avg(*l): f=0 for i in l: f+=i return (f/len(l)) if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') nums = list(map(int, input().split())) res = avg(*nums) fptr.write('%.2f' % res + '\n') fptr.close()

Average Function | hackerrank certification problem solution

__Recommended Post:__

- c program to convert specified days into years weeks and days

- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation

__Hackerrank Problems:-__- Playing With Characters | Hackerrank practice problem solution
- Sum and Difference of Two Numbers | hackerrank practice problem solution

- Functions in C | hackerrank practice problem solution

- Pointers in C | hackerrank practice problem solution

- Conditional Statements in C | Hackerrank practice problem solution

- For Loop in C | hackerrank practice problem solution

- Sum of Digits of a Five Digit Number | hackerrank practice problem solution

- 1D Arrays in C | hackerrank practice problem solution

- Array Reversal | hackerrank practice problem solution

- Printing Tokens | hackerrank practice problem solution

- Digit Frequency | hackerrank practice problem solution

- Calculate the Nth term | hackerrank practice problem solution

__Data structure:-__

- Program to find cycle in the graph
- Implementation of singly link list
- Implementation of queue by using link list
- Algorithm of quick sort
- stack by using link list
- program to find preorder post order and inorder of the binary search tree
- Minimum weight of spanning tree
- Preorder, inorder and post order traversal of the tree

__Must check this:-__

__ MCQs:-__