mirror of
https://github.com/VitaAetaerna/SubnetExerciseGenerator.git
synced 2025-01-18 08:31:36 +01:00
Update main.py
This commit is contained in:
parent
027427ae9e
commit
ae2d040c96
8
main.py
8
main.py
@ -32,7 +32,7 @@ def generateNetwork():
|
|||||||
# to avoid getting too large and too small networks
|
# to avoid getting too large and too small networks
|
||||||
# returns dict: {ip:int, prefix:int}
|
# returns dict: {ip:int, prefix:int}
|
||||||
ip = random.randint(0, 2**32-1)
|
ip = random.randint(0, 2**32-1)
|
||||||
prefix = random.randint(8, 30)
|
prefix = random.randint(8, 31)
|
||||||
ipandprefix = {"ip":ip, "prefix":prefix}
|
ipandprefix = {"ip":ip, "prefix":prefix}
|
||||||
return ipandprefix
|
return ipandprefix
|
||||||
|
|
||||||
@ -84,16 +84,16 @@ def newSubnetExercises(ip, prefix):
|
|||||||
print("Generating new Subnet exercise...")
|
print("Generating new Subnet exercise...")
|
||||||
aufgabentyp = random.randint(0,1)
|
aufgabentyp = random.randint(0,1)
|
||||||
bonusaufgabe = random.randint(0,10)
|
bonusaufgabe = random.randint(0,10)
|
||||||
newprefix = random.randint(prefix, 31)
|
newprefix = random.randint(prefix, 32)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(printDotted(intToDotted(ip)))
|
print(printDotted(intToDotted(ip)))
|
||||||
print("Prefix: ", prefix)
|
print("Prefix: ", prefix)
|
||||||
if aufgabentyp == 0:
|
if aufgabentyp == 0:
|
||||||
print("You will have to split the subnet into {} subnets".format(random.randint(2,10)))
|
print("You will have to split the subnet into {} subnets".format(random.randint(2,32-prefix-2)))
|
||||||
else:
|
else:
|
||||||
print("Split subnet into subnet with {} Hosts".format(random.randint(8,254)))
|
print("Split subnet into subnet with {} Hosts".format(random.randint(8,2**(32-prefix)/2)))
|
||||||
|
|
||||||
if bonusaufgabe > 5:
|
if bonusaufgabe > 5:
|
||||||
print("What is the Net ID of the given subnet?")
|
print("What is the Net ID of the given subnet?")
|
||||||
|
Loading…
Reference in New Issue
Block a user