I don’t think we should because we all have our one choices that we should achieved and we should show
Answer:
Check the explanation
Explanation:
223.1.17/24 indicates that out of 32-bits of IP address 24 bits have been assigned as subnet part and 8 bits for host id.
The binary representation of 223.1.17 is 11011111 00000001 00010001 00000000
Given that, subnet 1 has 63 interfaces. To represent 63 interfaces, we need 6 bits (64 = 26)
So its addresses can be from 223.1.17.0/26 to 223.1.17.62/26
Subnet 2 has 95 interfaces. 95 interfaces can be accommodated using 7 bits up to 127 host addresses can represented using 7 bits (127 = 27)
and hence, the addresses may be from 223.1.17.63/25 to 223.1.17.157/25
Subnet 3 has 16 interfaces. 4 bits are needed for 16 interfaces (16 = 24)
So the network addresses may range from 223.1.17.158/28 to 223.1.17.173/28
We can define a word as a group of characters without a space between them. To find the words of the input string , w can use split(delimiter) which returns a list of strings which had the defined delimiter between them in the input string.
def countWords(string):
words = string.split(" ")
count = len(words)
return count
Here we set the delimiter as the space character, and returned the length of the words list. I split each step into its own line for readability, however the function could be one line:
return len(string.split())
Here, no delimiter is specified. If one isn't given, it will default to split at any whitespace, including space.
Answer:
In Python:
import os.path
from os import path
fname = input("Filename: ")
if path.exists(fname):
with open(fname) as file_in:
lines = []
for line in file_in:
lines.append(line.rstrip('\n'))
f = open("stat.txt","r+")
f.truncate(0)
f = open("stat.txt", "a")
f.write("Names\tTotal\tSubjects\tAverage\n")
for i in range(len(lines)):
rowsum = 0; count = 0
nm = lines[i].split()
for j in nm:
if (j.isdecimal()):
count+=1
rowsum+=int(j)
average = rowsum/count
f.write(nm[0]+"\t %3d\t %2d\t\t %.2f\n" % (rowsum, count, average))
f.close()
else:
print("File does not exist")
Explanation:
See attachment for explanation where comments were used to explain each line