0% found this document useful (0 votes)
184 views

Lab 3

This document contains instructions and sample code for 3 questions on mathematical functions, strings, and objects in Python. Question 1 asks to write a program that takes an ASCII code as input and displays the corresponding character. Question 2 provides examples of using the format function to format numbers in different ways. Question 3 asks to write a program that takes employee data as input - name, hours worked, hourly pay rate, tax rates - and prints a payroll statement.

Uploaded by

Pia Corpuz
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
184 views

Lab 3

This document contains instructions and sample code for 3 questions on mathematical functions, strings, and objects in Python. Question 1 asks to write a program that takes an ASCII code as input and displays the corresponding character. Question 2 provides examples of using the format function to format numbers in different ways. Question 3 asks to write a program that takes employee data as input - name, hours worked, hourly pay rate, tax rates - and prints a payroll statement.

Uploaded by

Pia Corpuz
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 3: Mathematical Functions, Strings and Objects

Question 1: Write a program that receives an ASCII code (an integer between 0 and 127) and displays its character. For example, if the user enters 97, the program displays the character a. Here is a sample run:

Question 2: What are the outputs of the following commands: a- print(format(57.467657, "9.3f")) b- print(format(12345678.923, "9.1e")) c- print(format(5789.4, "<.2f")) d- print(format(45, "<5d")) e- print(format(0.457467657, "<9.3%"))

Question 3: . Write a program that reads the following information and prints a payroll statement: Employees name (e.g., Smith) Number of hours worked in a week (e.g., 10) Hourly pay rate (e.g., 9.75) Federal tax withholding rate (e.g., 20%) State tax withholding rate (e.g., 9%) A sample run is shown below:

You might also like