-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinked list.py
More file actions
68 lines (60 loc) · 1.55 KB
/
Copy pathLinked list.py
File metadata and controls
68 lines (60 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
# coding: utf-8
# In[2]:
# first try
class student_info:
def init(name):
self.name = name
def init(roll):
self.roll = roll
def init(marks):
self.marks = marks
def init(none):
self.none = none
def init(self):
if self.head == none:
def add_students(self, name, roll, marks):
name = input()
roll = int(input())
marks = int(input())
return name, roll, marks
name1 = input()
roll1 = int(input())
marks1 = int(input())
self.head = add_students(name1, roll1, marks1)
print(self.head)
# In[6]:
# second try
class Node:
def __init__(self,data):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
def append(self,data):
new_node=Node(data)
if self.head is None:
self.head = new_node
return
last_node = self.head
while last_node.next:
last_node=last_node.next
last_node.next= new_node
def print_list(self):
current_node=self.head
while current_node:
print(current_node.data,end=" -> ")
current_node=current_node.next
print("None")
llist = LinkedList()
stu_name = input()
stu_roll = input()
stu_marks = int(input())
stu_gpa = (stu_marks+20)/20
if stu_gpa>=2 and stu_gpa<4:
stu_gpa = 5
llist.append(stu_name)
llist.append(stu_roll)
llist.append(stu_gpa)
llist.print_list()