Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 51 pages
Summary

Samenvatting WPO Bedrijfsinformatica (alle oefeningen + oplossingen)

Document preview thumbnail
Preview 4 out of 51 pages

In dit document vind je alle oefeningen met de daarbij horende oplossingen terug samengevat in 1 enkel document. De oefeningen betreffen alle wpo's gezien in het academiejaar met assistent Mathias Hanson.

Content preview

Bedrijfsinformatica wpo’s H3-H9


H3: Python – data types en operatoren


Average Electricity Bill

My electricity bills for the last three months have been € 23, € 32 and € 64. What
is the average monthly electricity bill over the three-month period? Write an
expression to calculate the mean, and use print() to view the result.

# Write an expression that calculates the average of 23, 32 and 64
# Place the expression in this print statement
print((23 + 32 + 64)/3)




Calculations for a tiler

Two parts of a floor need tiling. One part is 9 tiles wide by 7 tiles long, the
other is 5 tiles wide by 7 tiles long. Tiles come in packages of 6.
- How many tiles are needed?
- You buy 17 packages of tiles containing 6 tiles each. How many tiles will be left
over?

# Fill this in with an expression that calculates how many tiles are needed.
print(9*7 + 5*7)

# Fill this in with an expression that calculates how many tiles will be left over.
print(17*6 - (9*7 + 5*7))




1

,Assign and Modify Variables

After each comment write a line of code that implements the instruction.
Note that this code uses scientific notation to define large numbers. 4.445e8 is
equal to 4.445 * 10 ** 8 which is equal to 444500000.0.

# The current volume of a water reservoir (in cubic metres)
reservoir_volume = 4.445e8

# The amount of rainfall from a storm (in cubic metres)
rainfall = 5e6

# decrease the rainfall variable by 10% to account for runoff
rainfall *= .9

# add the rainfall variable to the reservoir_volume variable
reservoir_volume += rainfall

# increase reservoir_volume by 5% to account for stormwater that flows
# into the reservoir in the days following the storm
reservoir_volume *= 1.05

# decrease reservoir_volume by 5% to account for evaporation
reservoir_volume *= 0.95

# subtract 2.5e5 cubic metres from reservoir_volume to account for water
# that's piped to arid regions.
reservoir_volume -= 2.5e5

# print the new value of the reservoir_volume variable
print(reservoir_volume)




2

,Which is denser, Rio or San Francisco?

Try comparison operators in this quiz! This code calculates the population
densities of Rio de Janeiro and San Francisco.
Write code to compare these densities. Is the population of San Francisco more
dense than that of Rio de Janeiro? Print True if it is and False if not.

sf_population, sf_area = 864816, 231.89
rio_population, rio_area = 6453682, 486.5
san_francisco_pop_density = sf_population/sf_area
rio_de_janeiro_pop_density = rio_population/rio_area

# Write code that prints True if San Francisco is denser than Rio, and False otherwise
print(san_francisco_pop_density > rio_de_janeiro_pop_density)

# Note: other solutions are possible, like the one below, but take a moment to make sure
you understand and appreciate the concise efficiency of the one line above!
if (san_francisco_pop_density > rio_de_janeiro_pop_density):
print (True)
else:
print (False)




3

, Write a Server Log Message

Youve learned to print a log message like this one (with the username, url, and timestamp
replaced with values from the appropriate variables):
John.McAfee accessed the site https://canvas.vub.be/courses/234097 at 12:53.

username = "Elizabeth.Smith"
timestamp = "09:11"
url = "https://canvas.vub.be/courses/189241"

# TODO: print a log message using the variables above.
print (username + " accessed the site " + url + " at " +
timestamp + ".")




Use string concatenation and the len() function to find the length of a certain
movie star's actual full name. Store that length in the name_length variable.
Don't forget that there are spaces in between the different parts of a name!

given_name = "William"
middle_names = "Bradley"
family_name = "Pitt"

# TODO: calculate how long this name is of name_length
name_length = len(given_name + " " + middle_names + " " +
family_name)
name_length = len(given_name) + len(middle_names) +
len(family_name) + 2


# Now we check to make sure that the name fits within the driving license character limit
# Nothing you need to do here
driving_license_character_limit = 28
print(name_length <= driving_license_character_limit)




4

Document information

Study
Uploaded on
September 12, 2023
Number of pages
51
Written in
2022/2023
Type
Summary
$7.45

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
insd
4.5
(2)
Sold
35
Followers
14
Items
4
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions