-
Take a input from user and find it’s total occurrences in a list without using count function. (Dynamic List only)
-
Find the sum of all the values in a list of int values. (Dynamic List only)
2 Likes
- Take a input from user and find it’s total occurrences in a list without using count function. (Dynamic List only)
size=int(input("Enter the size of the list"))
lst=[]
for i in range(size):
num=int(input("Enter the value"))
lst.append(num)
print(lst)
num2=int(input("Enter the value"))
rep=0
for i in lst:
if i==num2:
rep+=1
print("The no.of occurences of",num2,"in",lst,"is",rep)
- Find the sum of all the values in a list of int values. (Dynamic List only)
size=int(input("Enter the size of the list"))
lst=[]
for i in range(size):
num=int(input("Enter the value"))
lst.append(num)
print(lst)
sum1=0
for i in lst:
sum1+=i
print("The sum of all values in the",lst,"is",sum1)
1 Like
#Take a input from user and find it’s total occurrences in a list without using count function. (Dynamic List only)
endvalue =int(input("Enter the total number: "))
lst=[]
for i in range(0,endvalue+1):
addvalue =int(input("Enter the values: "))
lst.append(addvalue)
print(lst)
occurance =int(input("Enter the value to check occurance: "))
count=0
for i in lst:
if i== occurance:
count+=1
print(count)
#Find the sum of all the values in a list of int values. (Dynamic List only)
endvalue =int(input("Enter the total number of value: "))
lst =[]
for i in range(0,endvalue+1):
addvalues = int(input("Enter the values: "))
lst.append(addvalues)
print(lst)
sum =0
for i in lst:
sum =sum+i
print(sum)
1 Like
#python program to find sum of list int values(dynamic values)
size=int(input("enter no.of list elements"))
list1=[]
for num in range(size):
list1.append(num)
print(list1)
sum=0
for i in list1:
sum+=i
print("sum of list",sum)
output:-
enter no.of list elements10
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] sum of list 45
1 Like
#Take a input from user and find it’s total occurences in a list without using count function
total=int(input("enter the total number:"))
lst=[]
for i in range(total):
addvalue=int(input("enter the values"))
lst.append(addvalue)
print(lst)
occurance=int(input("enter the value to check occurance:"))
repeat=0
for i in lst:
if i == occurance:
repeat+=1
print(repeat)
output:
enter the total number:5
enter the values1
enter the values2
enter the values1
enter the values3
enter the values4
[1, 2, 1, 3, 4]
enter the value to check occurance:1
2
1 Like
# 1] Take a input from user and find it’s total occurrences in a list without using count function. (Dynamic List only)
num_size = int(input("Enter total elements for list : "))
lst = []
for i in range(num_size):
elements = input("Enter elements : ")
lst.append(elements)
print(lst)
str1 = int(input("enter the value : "))
count = 0
for i in lst:
if i == count:
count+=1
print("Total occurrences in a list : ",count)
# 2] Find the sum of all the values in a list of int values. (Dynamic List only)
num_size = int(input("Enter total elements for list : "))
lst = []
for i in range(num_size):
elements = input("Enter elements : ")
lst.append(elements)
print(lst)
total = 0
numsum = 0
for i in lst:
numsum+=int(i)
print('Sum of List : ',numsum)
1 Like
1.Take a input from user and find it’s total occurrences in a list without using count function. (Dynamic List only)
size = int(input("Enter total elements to be in the list:"))
lst = []
for i in range(0,size):
print("Enter",i+1, "element:")
elements = input()
lst.append(elements)
print(lst)
check_element = input("Enter the element to check:")
count = 0
for i in lst:
if i == check_element:
count += 1
print("The count of", check_element, "is:" ,count)
#2.Find the sum of all the values in a list of int values. (Dynamic List only)
size = int(input("Enter total elements to be in the list:"))
print()
lst = []
for i in range(0,size):
print("Enter",i+1, "element:")
elements = int(input())
print()
lst.append(elements)
print("The list of entered elements is:",lst)
print()
sum = 0
for i in lst:
sum += i
print("The sum of elements in list",lst, "is",sum)
print()
1 Like
my_list = []
n = int(input("Enter the number of elements in the list: "))
for i in range(n):
element = int(input("Enter the element:"))
my_list.append(element)
element_to_count = int(input("Enter the element to count: "))
count = 0
for item in my_list:
if item == element_to_count:
count += 1
print(count)
1 Like
2.
my_list = []
n =int(input("Enter the total number of value: "))
lst =[]
for i in range(0,n+1):
addvalues = int(input("Enter the values: "))
lst.append(addvalues)
total_sum = 0
for item in my_list:
total_sum += item
print(total_sum)
1 Like
1.lst=[]
count=0
range_number=int(input("enter range number:"))
for i in range(range_number):
number=int(input("enter number:"))
lst.append(number)
print("list:",lst)
# total=len(lst) it is using inbuiltfunction
check_occurence=int(input("enter occurence value:"))
for i in lst:
if i==check_occurence:
count+=1
print(count)
2.lst=[]
sum=0
range_number=int(input("enter range number:"))
for i in range(range_number):
number=int(input("enter number {}:".format(i+1)))
lst.append(number)
print("list:",lst)
for i in lst:
sum+=i
print("sum of values:",sum)
#Take a input from user and find it’s total occurrences in a list without using count function. (Dynamic List only)
size=int(input("enter size of list :"))
lst=[]
for i in range(size):
num=int(input("enter a value :"))
lst.append(num)
print(lst)
num2=int(input("enter a value to check :"))
rep=0
for i in lst:
if i ==num2:
rep+=1
print("occurences of",num2,"is",rep)
#Find the sum of all the values in a list of int values. (Dynamic List only)
size=(int(input("enter a size of list :")))
lst=[]
for i in range(size):
num=int(input("enter a value :"))
lst.append(num)
print(lst)
sum=0
for i in lst:
sum+=i
print("sum of values in a lst is :",sum)