Hvala na odgovoru, mada resio sam kod juce uspesno, nesto drugaciji nacin od tvog postavljenog koda, ali funkcionise. Hvala inace za sjajan primer, kod koji si prestavio znatno je kraci sto je svakako sjajno. proucicu malo detalje dobro ce doci za ubuduce.. :)
Code:
#encoding: utf8
from random import shuffle
print ()
print ("==============")
print ("| CISCO QUIZ |")
print ("==============\n")
print("[1] Starta Quiz")
print("[2] Avsluta")
print()
menu = int(input(" "))
if menu == 1:
aqpool = [("What contains the instructions that a router uses to control
the flow of traffic through its interfaces?", 'configuration files'),
("Which router component holds the configuration file when power is lost? ", 'non-violate random access memory'),
("What do routers use to select the best path for outgoing data packets?", 'routing tables'),
("What can cause a reduction in available bandwidth on a cable broadband connection?", 'number of subscribers'),
("What type of connectivity is established when VPNs are used from the remote site to the private network?", 'tunnels'),
("Which WAN technology uses a fixed payload of 48 bytes and is transported across both switched and permanent virtual circuits?", 'ATM'),
("Which term describes a device that will put data on the local loop?", 'DCE'),
("Which networking device is typically used to concentrate the dial-in and dial-out traffic of multiple users to and from a network?", 'access server'),
("What application layer protocol is commonly used to support for file transfers between a client and a server?", 'HTTP'),
("What is the automated service that matches resource names with the required IP address?", 'DNS'),
("As compared to SSH, what is the primary disadvantage of telnet?", 'does not support encryption'),
("With TCP/IP data encapsulation, which range of port numbers identifies all well-known applications?", '0-1023'),
(" Which OSI model layer is responsible for regulating the flow of information from source to destination, reliably and accurately?", 'transport'),
("What is dynamically selected by the source host when forwarding data?", 'source port')
]
playAgain = True
numRight = 0
guess = 0
while aqpool[0] and playAgain:
shuffle (aqpool)
for question, rightAnswer in aqpool:
answer = input(question + " ")
guess = guess + 1
if answer == rightAnswer:
print ("RÄTT SVAR!")
numRight = numRight + 1
else:
print("FEL SVAR! Rätta svaret är: " + rightAnswer + "\n")
print("Vill du försätta spela? (ja eller nej)")
playAgain = str(input()) not in ('n', 'nej')
if not playAgain:
break
total = (numRight / guess) * 100
print ("Du hade %s%% rätt!" % float(int(total)))
if menu == 2:
print ("\n=== HEJ DÅ ===\n")