Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3e1c9c7

Browse files
Add files via upload
1 parent f66ba03 commit 3e1c9c7

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

‎Nested Lists.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Given the names and grades for each student in a Physics class of
2+
3+
# students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.
4+
5+
# Note: If there are multiple students with the same grade, order their names alphabetically and print each name on a new line.
6+
7+
# Input Format
8+
9+
# The first line contains an integer,
10+
# , the number of students.
11+
# The subsequent lines describe each student over
12+
13+
# lines; the first line contains a student's name, and the second line contains their grade.
14+
15+
# Constraints
16+
17+
# There will always be one or more students having the second lowest grade.
18+
19+
# Output Format
20+
21+
# Print the name(s) of any student(s) having the second lowest grade in Physics; if there are multiple students, order their names alphabetically and print each one on a new line.
22+
23+
# Sample Input 0
24+
25+
# 5
26+
# Harry
27+
# 37.21
28+
# Berry
29+
# 37.21
30+
# Tina
31+
# 37.2
32+
# Akriti
33+
# 41
34+
# Harsh
35+
# 39
36+
37+
# Sample Output 0
38+
39+
# Berry
40+
# Harry
41+
42+
# Explanation 0
43+
44+
# There are
45+
46+
# students in this class whose names and grades are assembled to build the following list:
47+
48+
# python students = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti', 41], ['Harsh', 39]]
49+
50+
# The lowest grade of
51+
# belongs to Tina. The second lowest grade of belongs to both Harry and Berry, so we order their names alphabetically and print each name on a new line.
52+
53+
54+
55+
56+
57+
if __name__ == '__main__':
58+
n = int(input())
59+
list1 = []
60+
list2 = []
61+
62+
for i in range(0,n):
63+
name = input()
64+
score = float(input())
65+
list1.append([name,score])
66+
list2.append(score)
67+
68+
69+
list1.sort()
70+
list2.sort()
71+
m = min(list2)
72+
list2.remove(m)
73+
m2 = min(list2)
74+
75+
for i in range(len(list1)):
76+
for j in range(len(list1[i])):
77+
if list1[i][j] == m2:
78+
print(list1[i][0])
79+
80+
81+
82+
# marksheet=[]
83+
# scorelist=[]
84+
# if __name__ == '__main__':
85+
# for _ in range(int(input())):
86+
# name = input()
87+
# score = float(input())
88+
# marksheet+=[[name,score]]
89+
# scorelist+=[score]
90+
# b=sorted(list(set(scorelist)))[1]
91+
92+
# for a,c in sorted(marksheet):
93+
# if c==b:
94+
# print(a)

‎Print_function.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Read an integer
2+
3+
# .
4+
5+
# Without using any string methods, try to print the following:
6+
7+
# Note that "
8+
9+
# " represents the values in between.
10+
11+
# Input Format
12+
13+
# The first line contains an integer
14+
15+
# .
16+
17+
# Output Format
18+
19+
# Output the answer as explained in the task.
20+
21+
# Sample Input 0
22+
23+
# 3
24+
25+
# Sample Output 0
26+
27+
# 123
28+
29+
30+
31+
from __future__ import print_function
32+
j=1
33+
if __name__ == '__main__':
34+
n = int(raw_input())
35+
36+
for i in range(0,n):
37+
print(j,end="")
38+
j+=1

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /