-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathassbot.py
194 lines (168 loc) · 5.38 KB
/
assbot.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import fire
import os
import shutil
# nice code rahul
def create(name):
try:
os.mkdir(f"{name}")
shutil.copy2('cet-logo.jpeg', f'{name}/cet-logo.jpeg')
shutil.copy2('demo.png', f'{name}/demo.png')
os.chdir(f"{name}")
f = open(f"{name}.md", "w")
f.write(
r"""
<style>
body{
max-width: 80%;
margin: auto;
font-family: 'Times New Roman', Times, serif;
line-height: 2rem;
}
.main-page{
max-width: 80%;
min-height: 100vh;
margin: auto;
text-align: center;
line-height: 1rem;
}
.clg-name{
font-size: 30px;
font-weight: 300;
}
.ass-heading{
font-size: 45px;
font-weight: 900;
margin-top: 50px;
}
.name{
font-size: 28px;
}
.dept-name{
font-size: 28px;
font-weight: 300;
margin-top: 100px;
}
</style>
<div class="main-page">
<p class="clg-name">
College Of Engineering Trivandrum
</p>
<h1 class="ass-heading">
Object Oriented Programming using Python
</h1>
<img src="./cet-logo.jpeg" alt="">
<br><br><br>
<p class="name">Rahul T</p>
<p class="name">S3 CSE Roll No:53</p>
<br>
<p class="name">TVE19CS053</p>
<p class="dept-name">
Department of Computer Science <br><br>
Aug 20, 2020
</p>
</div>
# Question 1
## Aim
To implement and simulate algorithm for link state routing protocol.
## Theory
**Link-State Routing Protocols** are one of the two main classes of routing protocols used in packet switching networks for computer communications, the other being distance-vector routing protocols. Examples of link- state routing protocols include Open Shortest Path First (OSPF) and Intermediate System to Intermediate System (IS-IS).
The link-state protocol is performed by every switching node in the network (i.e., nodes that are prepared
to forward packets; in the Internet, these are called routers). The basic concept of link-state routing is that
every node constructs a map of the connectivity to the network, in the form of a graph, showing which nodes
are connected to which other nodes. Each node then independently calculates the next best logical path from
it to every possible destination in the network. Each collection of best paths will then form each node’s routing
table.
## Algorithm
```algorithm
START
Step 1: Take integer variable A
Step 2: Divide the variable A with (A-1 to 2)
Step 3: If A is divisible by any value (A-1 to 2) it is not prime
Step 4: Else it is prime
STOP
```
## code
```c
#include <stdio.h>
int main() {
int i, number;
int prime = 1;
printf("\nEnter a number: ");
scanf("%d", &number);
for(i = 2; i < number; i++) {
if((number % i) == 0) {
prime = 0;
}
}
if (number == 1)
printf("1 is neither prime nor composite \n\n");
else if (prime == 1)
printf("%d is prime number.\n\n", number);
else
printf("%d is not a prime number\n\n.", number);
return 0;
}
```
## Output
![alt text](demo.png "Title")
## Result
Implemented the program for simulating Link State Routing Protocol in c and was compiled using gcc and
executed in Ubuntu and the above output was obtained.
<br><br><br><br><br>
--------
# Question 2
## Aim
To implement and simulate algorithm for link state routing protocol.
## Theory
**Link-State Routing Protocols** are one of the two main classes of routing protocols used in packet switching networks for computer communications, the other being distance-vector routing protocols. Examples of link- state routing protocols include Open Shortest Path First (OSPF) and Intermediate System to Intermediate System (IS-IS).
The link-state protocol is performed by every switching node in the network (i.e., nodes that are prepared
to forward packets; in the Internet, these are called routers). The basic concept of link-state routing is that
every node constructs a map of the connectivity to the network, in the form of a graph, showing which nodes
are connected to which other nodes. Each node then independently calculates the next best logical path from
it to every possible destination in the network. Each collection of best paths will then form each node’s routing
table.
## Algorithm
```algorithm
START
Step 1: Take integer variable A
Step 2: Divide the variable A with (A-1 to 2)
Step 3: If A is divisible by any value (A-1 to 2) it is not prime
Step 4: Else it is prime
STOP
```
## code
```c
#include <stdio.h>
int main() {
int i, number;
int prime = 1;
printf("\nEnter a number: ");
scanf("%d", &number);
for(i = 2; i < number; i++) {
if((number % i) == 0) {
prime = 0;
}
}
if (number == 1)
printf("1 is neither prime nor composite \n\n");
else if (prime == 1)
printf("%d is prime number.\n\n", number);
else
printf("%d is not a prime number\n\n.", number);
return 0;
}
```
## Output
![alt text](demo.png "Title")
## Result
Implemented the program for simulating Link State Routing Protocol in c and was compiled using gcc and
executed in Ubuntu and the above output was obtained.
<br><br>
"""
)
f.close()
return f"\n files created successfully at {os.getcwd()} \n"
except FileExistsError:
print('\n This file name already exist ..\n')
if __name__ == '__main__':
fire.Fire()