Spørsmål fra tidligere eksamener Flashcards
Hva skrives ut med følgende kommando?:
print(“The problem is not the problem”[4:11])
problem
Hva skrives ut med følgende kommando?:
print(“The problem is you attitude about the problem”.split())
[‘The’, ‘problem’, ‘is’, ‘you’, ‘attitude’, ‘about’, ‘the’, ‘problem’]
Hva skrives ut med følgende kommando?:
print(“Do or do not”.find(“do”))
6
Hva skrives ut med følgende kommando?:
print(“There is no try”.upper())
THERE IS NO TRY
Hva skrives ut med følgende kommando?:
print(“My favourite courses: {2}, {0}, {3}, {1}”.format(“fys230”, “inf120”, “math112”, “stat100”))
My favourite courses: math112, fys230, stat100, inf120
Hva skrives ut med følgende kommando?:
print(“Cartoon”.replace(“o”, “a”))
Cartaan
Hva skrives ut med følgende kommando?:
print(int(10.0/int(“2”)))
5
Hva skrives ut med følgende kommando?:
print(“*“.join([“student”, “at”, “NMBU”.lower()]))
studentatnmbu
Hva skrives ut med følgende kommando?:
print(“The person is {0:.2f} m tall, weighs {2} kg and has shoe size {1}.”.format(1.5999, 40, 45))
The person is 1.60 m tall, weighs 45 kg and has shoe size 40.
Hva skrives ut med følgende kommando?:
print(27 == 42)
False
Hva skrives ut med følgende kommando?:
print(“Pizza with ham and cheese.”.replace(“ham”, “pepperoni”))
Pizza with pepperoni and cheese.
Hva skrives ut med følgende kommando?:
print(“The best mirror is an old friend.”.split()[-3:-1])
[‘an’, ‘old’]
Hva skrives ut med følgende kommando?:
print(“house”.upper() in “The house is on fire”)
False
Hva skrives ut med følgende kommando?:
print(“Always remember: it is never too late”.split(“:”)[0].split()[0][0:-3])
Alw
Hva vil denne listen inneholde om den printes?:
[e + f for e, f in [[4, 2], [4, 3]]]
[6, 7]