BIS1003-Introduction to Programming Intensive

profileAbdulmalek
BIS1003_Workshop_Topic8.pdf

BIS1003 Introduction to Programming

Workshop 8

Topic 8: Sequences and lists

Apply and test your knowledge of the current and previous topics by attempting the

questions below. Completing these questions will help you to succeed in your subject.

Complete workshop-8 activities and submit your work during the workshop session.

Workshop Questions

1. Dice Rolls

Write a program that rolls a dice several times as specified by the user. The program

should contain a roll function with an integer parameter number_of_rolls. The

function simulates a dice roll (generates a random number 1 to 6) and appends the

result to a list. Upon completing number_of_rolls iterations, the list must be returned

to the main function that displays the list. If the user enters 10 rolls, the program will

show a list of 10 dice roll results.

2. employee Records

This task aims to create a list for storing employees records. Consider an employee

record consists of following fields: employee_id, Last Name, First Name, and Salary.

Write a program that gets employee data from the user and stores those as records

in a list called employees. You must validate the Salary input so that it only contains

a number between 0 and 10000. In the beginning, the program should also prompt

the user for the number of employee records.

Note: The employee list will have a structure like this: ['123', 'John', 'Sam', 850.0,

'456', 'Jane', 'Mary', 650.0, ...] (four elements per employee)

3. Distinguished employees

Extend the program in task 2 to display details of all employees their salary above

$7000. You must use slicing operations to extract information of an employee from

the full list.