Python Problem Solving

2/ 30 Day Solution #python #pythonproblemsolving #30daycodingchallenge #30daychallenge #problemsolving

if name == '__main__':

# taking input from user of how many elements(names) to add in dictionary

n = int(input())

# initiating a dictionary which store the marks as set of marks

student_marks = {}

# looping the process of taking input and storing the students name and marks data in dictionary

for _ in range(n):

name, *line = input().split()

scores = list(map(float, line))

student_marks[name] = scores

# taking input from user for which name we have to calculate the average marks

query_name = input()

# intializing a set to store marks

scores = {}

# iterating through each marks the set

for name in student_marks:

if name == query_name:

scores = student_marks[query_name]

sum = 0

for score in list(scores):

sum += score

print("{:.2f}".format(sum/len(list(scores))))

要查看或添加评论,请登录

KUNAL V.的更多文章

  • Problem of the Day

    Problem of the Day

    We have seen that lists are mutable (they can be changed), and tuples are immutable (they cannot be changed). Let's try…

  • Solution of the Day

    Solution of the Day

    def print_full_name(first, last): # Write your code here string = "Hello"+" "+first+" "+last+"! You just delved into…

  • Solution of the Day

    Solution of the Day

    def split_and_join(line): # write your code here line = line.split(" ") line = "-".

  • Problem of The Day

    Problem of The Day

    You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase…

  • Problem of the Day

    Problem of the Day

    Print the following pattern Write a program to print the following start pattern using the loop Solution for the same…

  • Solution of The Day

    Solution of The Day

    if name == '__main__': n = int(input()) integer_list = tuple(map(int, input().split())) has_value = hash(integer_list)…

  • Solve this Problem

    Solve this Problem

    Given an integer, , and space-separated integers as input, create a tuple, , of those integers. Then compute and print…

  • Answer For Today's Coding Problem

    Answer For Today's Coding Problem

    if name == '__main__': # Read the number of operations N = int(input()) # Initialize an empty list L = [] # Loop…

  • How would you approach this problem? Comment your answer

    How would you approach this problem? Comment your answer

    Consider a list (list = []). You can perform the following commands: insert i e: Insert integer at position .

社区洞察

其他会员也浏览了