Coding Exercise for Beginners in Python |Exercise 14 | Python Tutorials for Beginners #lec44

preview_player
Показать описание
Python program to calculate average height from a list of heights ( Don't use sum() and len() functions and take use input using input() function)
hint: use split() and range() functions

*********************************************

Connect & Contact Me:

*******************************************

More Playlists:

#coding #pythonforbeginners #python #jennyslectures #pythonprogramming #loop
Рекомендации по теме
Комментарии
Автор

l=input('enter heights separated by space').split()
sum=0
count=0
for i in l:
sum+=int(i)
for i in l:
count=count+1
avg=round(sum/count)
print(f"average height is {avg}")

seenumadhavan
Автор

I started following you in 2019. You make everything about CS simple even where looks hard. That is why I love learning from you! You are the best and keep it up, Jenny!

abebebiru
Автор

Thank you for your videos Jenny! Your videos are very helpful! Go on!☘

fitoremorina
Автор

You're killing it with your content, just subscribed to support you!

MyCodingDiary
Автор

Excellent explanation mam even who don't know about coding they can also easily understand your lectures🎉🎉❤❤😊

venkateswarlugoud
Автор

Excellent explanation mam. Keep continuing this course

vigneshk
Автор

I love your videos ❣️
And way of teaching 😊

KEVIN-tygo
Автор

Your videos are so informative and entertaining, I just subscribed!

MyCodingDiary
Автор

I am watching your python series since morning I love your videos❤❤❤

venkateswarlugoud
Автор

Your content is amazing, I just subscribed!

MyCodingDiary
Автор

no need to use double "for loop" or "range", if we are not disturbing input list, the following approach can more efficient

height=input("enter height list separated by space:").split()
total_height=0
count=0
for i in height:
i=int(i)
total_height+=i
count=count+1
else:

PushpendraSinghDangi
Автор

list1 = [int(x) for x in input().split()] #we can directly take input from user and convert it into a list and values into integer form with this 1 step..thank me later😉😉

Fullstackdeveloper
Автор

Jenny, I didnt understood the line total=total + person(Why person was incrementing). Please explain, it will be helpful to understand the 3rd part total concept.

rupayadav
Автор

Mam, will you be covering OOPS??
PLEASE reply mam

sucharithapatnana
Автор

user_input = input("enter the height: ")
new_input = user_input.split()
print(new_input)

for i in range(0, len(new_input) - 1):
new_input[i] = int(new_input[i])

total = 0
for height in new_input:
total = total+int(height)
avg = total/(len(new_input))
print(avg)

MARUTHU_
Автор

What about using FLOOR DIVISION for round of values😅

tamilselvan.s
Автор

I assume if the user does not put space to all the numbers inputed, how do we takw care of that.

incomparablevikkie
Автор

heights = input("Enter value by space").split()
sum = 0.0
j = 0
for i in heights:
j +=1
sum += int(i)
else:
print(i)
avg = sum // j
print(avg)

AmanMomin-sjsd
Автор

l1 = input("enter the Hight Seprated by comma").split(', ')
total_height = 0
count = 0
for i in l1:
total_height += int(i)
count += 1
print(round(total_height / count))

prakhargupta
Автор

h = input("enter your heights: ")
count, total = 0, 0
height = h.split(", ")
for i in height:
total=total+int(i)
count=count+1
average = total/count
print(round(average))

sandhyatoleti