BIS1003_Workshop_Topic2.pdf

BIS1003 Introduction to Programming

Workshop 2

Topic 2: Input, Processing, and Output

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-2 activities and submit your work during the workshop

session.

Workshop Questions

Use your algorithms from last week to implement the following Python programs:

1. Write a Python program to ask the end user to enter the length and the width

of a rectangle in centimetre and then calculates and displays the rectangle

area in meters. 1 cm = 1/100 m.

2. Write a Python program that asks the end user to enter a temperature in

Fahrenheit temperatures (F) and then convert to Celsius units (C) and

displays it to the user. C = (F – 32) /1.8

3. Write a Python programs to enter a positive number. Then the program

calculates and displays the double of the number.

4. Assume a company purchased some stock in Software Ltd. six months ago.

The details of the purchase are:

• The number of shares that the company purchased was 400.

• When the company purchased the stock, it paid $20.05 per share.

• It paid the stockbroker a commission that amounted to 2.2 percent

of the amount the company paid for the stock.

One month later, the company sold the stock. The details of the sale are:

• The number of shares that the company sold was 400.

• It sold the stock for $32.03 per share.

• It paid the stockbroker another commission that amounted to 2.2

percent of the amount the company received for the stock.

Write a program that shows the following amounts:

• money that the company paid for the stock.

• commission that the company paid the broker on buying the

stock.

• amount that the company sold the stock for

• commission that the company paid the broker on selling the stock.

• net profit the company made in stock business.