Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Write an expression that calculates the average of 23, 32 and 64
# Place the expression in this print statement
print((23 +32 + 64)/3)

# Fill this in with an expression that calculates how many tiles are needed.
tiles_needed = (9*7) + (5*7)
total_tiles = 17 * 6

print(tiles_needed)

left_tiles = total_tiles - tiles_needed

# Fill this in with an expression that calculates how many tiles will be left over.
print(left_tiles)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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 *= 0.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)
14 changes: 14 additions & 0 deletions workspace/50_udacity/2_data_type_and_operators/quiz/3_bool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Booleans, Comparison Operators, and Logical Operators
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
if(san_francisco_pop_density > rio_de_janeiro_pop_density):
print("True")
else:
print("False")

print(san_francisco_pop_density > rio_de_janeiro_pop_density)
29 changes: 29 additions & 0 deletions workspace/50_udacity/2_data_type_and_operators/quiz/4_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# TODO: Fix this string!
ford_quote = "Whether you think you can, or you think you can't--you're right."

username = "Yogesh"
timestamp = "16:20"
url = "http://petshop.com/pets/reptiles/pythons"

# TODO: print a log message using the variables above.
# The message should have the same format as this one:
# "Yogesh accessed the site http://petshop.com/pets/reptiles/pythons at 16:20."
message = username + " accessed the site " + url + " at " + timestamp + "."
print(message)

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

full_name = given_name + " " + middle_names + " " + family_name
name_length = len(full_name)

# name_length = len(given_name + middle_names + family_name) + 2. The +2 accounts for the spaces in between each word.

# 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)

# print(len(835)) # error len only works on sequences, not numbers