AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Cases and lists

Week 8 · 1.5 Programming with data · 3 lessons
Answers are for parents and teachers.
1
Write a program that asks for a colour and prints Stop if the user types red in any mix of capitals and small letters, and Go for anything else. What does it print for RED, Red and green?
2
Give the value of "Go-Kart".upper(), "ABC123".lower() and "x".upper().
3
The list is fruit = ["mango", "pear", "plum", "fig", "lime"]. Which items are fruit[2] and fruit[len(fruit) - 1]? How many items are there before and after fruit.append("kiwi")?
4
This program stops with an error. Give the message and correct the program.
Python
1items = [4, 6]
2for p in items:
3    total = total + p
4print(total)
5
Give two differences between an array and a Python list, and one thing they have in common.