Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Programming Practice-Problem Questions and Detailed Solutions - Volume (Introductory Exercises)
Description: The document consists of Python programming problems and exercises as well as the detailed solution and explanation for each practice question.

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


PROGRAMMING PRACTICE-PROBLEM QUESTIONS AND
DETAILED SOLUTIONS - INTRODUCTORY EXERCISES
Volume 1

1

Contents
1

Problem to Display Personal Information
...
1

Program
...
2

Output
...
3

2
...
3

2
...
4

3

Problem to Calculate the Perimeter of a Lawn Tennis Court
...
1

Program
...
2

Output
...
4

4
...
5

4
...
5

5

Problem to Compute the Four Simple Arithmetic Operations
...
1

Program
...
2

Output
...


1
...

print("Last Name: Doe")
print("Gender: Male")
print("Date of Birth: 01-01-1900")
print("Department: Information and Computer Science")

1
...
Let the program
reply each for the user’s information by using the user’s typed responses
...
1 Program
name = input("What is your name?\n")
#input is a keyword to request and accept value from the user
#\n is used to start a newline, otherwise the text to be typed would have continued from the
preceding line
print("I am happy to meet you, " + name)
#+ is used for concatenating (joining) strings ("I am happy to meet you, " and name)
dept = input("Which department are you?\n")
print("Nice, you are welcome to the " + dept + " department")

3

2
...
Ensure your program will be robust enough to work with decimal
values
...
1 Program
length = float(input("How long is the court?\n"))
#float is a keyword for specifying that a data type of decimal can be allowed
width = float(input("How wide is the court?\n"))
perimeter = 2*(length + width)
#Recall that perimeter is the sum of all sides = 2*length + 2*width
print("The perimeter of the lawn tennis court = " + str(perimeter) + " square units")
#Take note of the str
...


3
...
3
How wide is the court?
11
...
8 square units

4

Problem to Calculate Simple Interest
Write a computer program that will assist your dad to compute the simple interest he will
earn if he invests a certain amount of his money in dollars for some number of years at a
particular percentage per annum
...


4

4
...
2 Output
Please enter the amount invested
200
Please enter the number of years?
3
Please enter the percentage
2
...
0

5

Problem to Compute the Four Simple Arithmetic Operations
Develop a computer program to model a calculator that will be able to perform the
arithmetic operations of addition, subtraction, multiplication, and division
...


5
...
2 Output
First Number:
3
Second Number:
2
3
...
0 = 5
...
0 - 2
...
0
3
...
0 = 6
...
0 / 2
...
5

6


Title: Programming Practice-Problem Questions and Detailed Solutions - Volume (Introductory Exercises)
Description: The document consists of Python programming problems and exercises as well as the detailed solution and explanation for each practice question.