File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -16,3 +16,36 @@ def voting_age(name,age):
1616# Enter the name and age with single whitespace: Harrish 19
1717# Hi Harrish!. You are eligible for voting your age is 19
1818
19+
20+ # Assignment 4:
21+ # Calculate the average mark and check eligible fo admission or not
22+ def admission_mark (name ,marks ):
23+ marks = list (map (int , marks ))
24+ subject = len (marks )
25+ total_mark = sum (marks )
26+ avg = total_mark // subject
27+ if avg > 60 :
28+ print (f'Hi { name } !. you are eligible for taking admission your score is { avg } ' )
29+ else :
30+ print (f'Hi { name } !. Sorry you are not eligible for taking admission still you need { 60 - avg } marks' )
31+
32+ try :
33+ user_data = input ('Enter the name after enter two whitespaces for marks single space:' ).split ()
34+ name = user_data [0 ]
35+ marks = user_data [1 :]
36+ admission_mark (name ,marks )
37+ except ValueError :
38+ print ('please enter the valid input' )
39+
40+ # Output:
41+ # Enter the name after enter two whitespaces for marks single space:Harrish 100 100 100 0
42+ # Hi Harrish!. you are eligible for taking admission your score is 75
43+
44+ # Time Complexity:
45+ # map(int, marks): O(n)
46+ # sum(marks): O(n)
47+ # Other operations (len(), division, comparison, and printing): O(1)
48+ # Thus, the overall time complexity of the function is dominated by the map() and sum() operations,
49+ # both of which have O(n) complexity.
50+
51+ # Time Complexity: O(n), where n is the number of marks in the input.
You can’t perform that action at this time.
0 commit comments