Python | Fundamentals of Programming

Fundamentals of Programming

联系我们: 手动添加方式: 微信>添加朋友>企业微信联系人>13262280223 或者 QQ: 1483266981

Fundamentals of Programming

Practical Test 1

Questions

1. Using the terminal, create a PracTest1 directory. (0.5 mark)

2. In the PracTest1 directory

a. create a README file using vim. Update for PracTest1. (0.5 mark)

b. create a Python file called strings.py using vim. Ask a user to input a string and a character to find in that string. Using for and if statement, display the character and its location. (1.5 marks)

c. create a Python file called lists.py using vim. In this file, create a list called “fruits” containing the following items: “apple”, “mango” , “cherry” , “banana” , and “ peach” . (0.5 mark)

d. add a for loop to print out all the items in the “fruits” list. (0.5 mark)

e. create a new list that consists of items in the “fruits” list with their first characters removed and print the new list. Your new list should look like [‘pple’, ‘ango’, ‘herry’, ‘anana’, ‘each’]. Use for, append and slicing. (1.5 mark)

Submission

1. Marking

Get your work marked by a tutor during the lab class.

2. Submit your work

Zip your PracTest1 directory and upload to Moodle. To create a zip file, go to the directory containing PracTest1 and type the following (replace studentID with your student ID).

zip PracTest1_studentID *

发表回复