我有一个python程序/脚本是一个在Windows中运行的测验程序,我需要知道添加/删除代码的方法,以使其在Ubuntu中运行。我研究了无数的论坛,并没有得到非常清晰的信息。非常感激。这是代码......几乎没有Linux经验,我迷路了。我认为它需要一些新的语法才能使它运行但我不在这里。
print("Here is a quiz to test your trivia knowledge...")
print()
print()
print("Question 1")
print("What month does the New Year begin? a=dec, b=Jan, c=Feb, d=Mar: ")
print()
answer = input("Make your choice >>>> ")
if answer == "a":
print("Correct!")
elif answer != "a":
print ("Wrong")
print()
print()
print("Question 2")
print("an antipyretic drug reduces what in humans? a=fever, b=weight, c=hair, d=acne: ")
print()
print()
answer = input("Make your choice >>>> ")
if answer == "a":
print("Correct!")
elif answer != "a":
print ("Wrong")
print()
print()
print("Question 3")
print("Which artist performed the 1992 hit song titled Save the best For Last? a=Prince, b=U2, c=Vanessa Williams, d=cher: ")
print()
answer = input("Make your choice >>>> ")
if answer == "c":
print("Correct!")
elif answer != "c":
print ("Wrong")
print()
print()
print("Question 4")
print("Columbus day in the US is celebrated during which month? a=dec, b=Jan, c=Oct, d=Jun: ")
print()
answer = input("Make your choice >>>> ")
if answer == "c":
print("Correct!")
elif answer != "c":
print ("Wrong")
print()
print()
print("Question 5")
print("What is the largest ocean in the world? a=Indian, b=atlantic, c=Pacific, d=baltic: ")
print()
answer = input("Make your choice >>>> ")
if answer == "c":
print("Correct!")
elif answer != "c":
print ("Wrong")
print()
print()
print("Question 6")
print("Which European city hosted the 2004 Summer Olympic Games? a=Rome, b=Paris, c=Vienna, d=athens: ")
print()
answer = input("Make your choice >>>> ")
if answer == "d":
print("Correct!")
elif answer != "d":
print ("Wrong")
print()
print()
print("Question 7")
print("Which NFL team has played in the most Superbowls? a=dallas, b=Pittsburgh,c=atlanta, d=chicago: ")
print()
answer = input("Make your choice >>>> ")
if answer == "a or b":
print("Correct!")
elif answer != "a or b":
print ("Wrong")
print()
print()
print("Question 8")
print("Which US president is on the $1 bill? a=Washington, b=Lincoln, c=Jefferson, d=Clinton: ")
print()
answer = input("Make your choice >>>> ")
if answer == "a":
print("Correct!")
elif answer != "a":
print ("Wrong")
print()
print()
print("Question 9")
print("What is the official language of Iran? a=English, b=German, c=Persian, d=Dutch: ")
print()
answer = input("Make your choice >>>> ")
if answer == "c":
print("Correct!")
elif answer != "c":
print ("Wrong")
print()
print()
print("Question 10")
print("Which flower, herb and perfume ingredient can be found in abundance in Provence, France? a=rose, b=tulip, c=lavender, d=rose: ")
print()
answer = input("Make your choice >>>> ")
if answer == "c":
print("Correct!")
elif answer != "c":
print ("Wrong")
print ("\n|Congratulations!")
print ("|Here's your result.")
print ("|Total score: " + str(count) + "/10")
division = float(count)/float(20)
multiply = float(division*100)
result = round(multiply)
print ("|Total percentage is", int(result), "%")
if result >= 95:
print ("|Grade: a+ \n|Well done!")
elif result >= 80:
print ("|Grade: b \n|Good job!")
elif result >= 65:
print ("|Grade: c \n|You did okay.")
elif result >=50:
print ("|Grade: d \n|Keep trying, that wasn't very good.")
elif result >= 0:
print ("|Grade: Fail\n|You need to study.")
答案 0 :(得分:1)
您可以尝试使用,因为Python已预装在Ubuntu中。
对于2.X:
python filename.py
对于3.X:
python3 filename.py