From 2e951f1d2f7ea4adf0b744fffc51207086ec19b1 Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Mon, 16 Jul 2018 12:17:19 +0100 Subject: [PATCH 01/12] added my ide files to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index ad46b308..0088af8e 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ typings/ # next.js build output .next + +# IDE +.idea From 4043553949bae419f8e0d8316f393d4b47ea7d7e Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Tue, 17 Jul 2018 11:17:32 +0100 Subject: [PATCH 02/12] fixed merge conflicts --- summer-of-code/week-01/calc.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/summer-of-code/week-01/calc.py b/summer-of-code/week-01/calc.py index e6cdde25..457fb18d 100644 --- a/summer-of-code/week-01/calc.py +++ b/summer-of-code/week-01/calc.py @@ -1,5 +1,3 @@ -# calculator - # print(1+2) # print(3) @@ -30,7 +28,7 @@ # print('2 * 5') # print('12' + 12) -#print('12' + str(12)) +# print('12' + str(12)) # print('2' * '5') @@ -40,11 +38,4 @@ print('You\'re swell!') print('backslash at the end of a string: \\') print('up\\down') -print('up\down') - - - - - - - +print('up\down') \ No newline at end of file From 364a4cab9c39dcd5c2a72ed2ea62ddc21101f314 Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Tue, 17 Jul 2018 11:48:34 +0100 Subject: [PATCH 03/12] certification exercises first go --- .../soc-wk1-cert-cristina-tarantino.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py diff --git a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py new file mode 100644 index 00000000..c4eaedd5 --- /dev/null +++ b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py @@ -0,0 +1,43 @@ +# 1. Hours in a year. How many hours are in a year? +# a day has 24h and a year has 365 days +# therefore +# 1 common year = 365 days = (365 days) times (24 hours/day) = 8760 hours +print +print "Hours in a year:" +print(24*365) + + +# 2. Minutes in a decade. How many minutes are in a decade? +# 60 (minutes in 1 hour) times 24 (hours in a day) times 365 times 10 = 5256000 (Integer) +print +print "Minutes in a decade:" +print(60*24*365*10) + +# If we want to be more accurate though we should know that +# a year is actually 365.2422 making the calculation = to 5259487.68 (Float) +# source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day +print +print "Minutes in a decade considering leaps:" +print(60*24*365.2422*10) + + +# Seconds in a year +# a year is actually 365.2422 making the calculation = to 31556926.08 (Float) +# source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day +print +print "Seconds in a year considering leaps:" +seconds_in_a_year = 60*60*24*365.2422 +print(seconds_in_a_year) + +# 3. Your age in seconds. How many seconds old are you? +print +print "My age in seconds:" +print(seconds_in_a_year*32) + + +# 4. Andreea Visanoiu is 48618000 seconds old. Calculate her age +seconds_in_year = 60*60*24*365.2422 +andrea_seconds_old = 48618000 +print +print "Andreea's age:" +print(andrea_seconds_old/seconds_in_year) From 4f663ec7cdbae6e71c7f52ab0e6fa58cf6f932ff Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Tue, 17 Jul 2018 15:30:06 +0100 Subject: [PATCH 04/12] implemented solutions for soc-wk1-cert --- .../soc-wk1-cert-cristina-tarantino.py | 69 ++++++++++++++----- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py index c4eaedd5..472d8212 100644 --- a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py +++ b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py @@ -1,43 +1,80 @@ +from datetime import datetime + +days_in_year = 365 +days_in_year_leap = 365.2422 +seconds_in_a_day = 60*60*24 +seconds_in_a_year = seconds_in_a_day*days_in_year +seconds_in_a_year_leap = seconds_in_a_day*days_in_year_leap + # 1. Hours in a year. How many hours are in a year? # a day has 24h and a year has 365 days # therefore # 1 common year = 365 days = (365 days) times (24 hours/day) = 8760 hours print print "Hours in a year:" -print(24*365) +print(24*days_in_year) # 2. Minutes in a decade. How many minutes are in a decade? # 60 (minutes in 1 hour) times 24 (hours in a day) times 365 times 10 = 5256000 (Integer) print print "Minutes in a decade:" -print(60*24*365*10) +print(60*24*days_in_year*10) # If we want to be more accurate though we should know that # a year is actually 365.2422 making the calculation = to 5259487.68 (Float) # source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day print print "Minutes in a decade considering leaps:" -print(60*24*365.2422*10) +print(60*24*days_in_year_leap*10) -# Seconds in a year -# a year is actually 365.2422 making the calculation = to 31556926.08 (Float) -# source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day -print -print "Seconds in a year considering leaps:" -seconds_in_a_year = 60*60*24*365.2422 -print(seconds_in_a_year) - # 3. Your age in seconds. How many seconds old are you? print print "My age in seconds:" -print(seconds_in_a_year*32) +print(seconds_in_a_year_leap*32) -# 4. Andreea Visanoiu is 48618000 seconds old. Calculate her age -seconds_in_year = 60*60*24*365.2422 -andrea_seconds_old = 48618000 +# 4. Andreea is 48618000 seconds old. Calculate her age +andreea_seconds_old = 48618000 print print "Andreea's age:" -print(andrea_seconds_old/seconds_in_year) +print(andreea_seconds_old/seconds_in_a_year_leap) + +# https://github.com/1millionwomentotech/toolkitten/issues/35 +print +print "Andreea's corrected age:" +print(andreea_seconds_old/seconds_in_a_year_leap*24) + +# 5. How many days does it take for a 32-bit system to timeout, if it has a bug with integer overflow? +# The Binary Register Width of a processor determines the range of values that can be represented. +# The maximum representable value for a 32-bit system will be 2^32-1 +# When an arithmetic operation (in this case the increment of a millisecond in the time) +# produces a result larger than the above we will have an `integer overflow` +# To calculate the days it will take to reach that situation for a 32-bit system +# we need to convert 2^32 milliseconds in days by dividing by 1000s then 60s then 60m 24h +# source https://en.wikipedia.org/wiki/Integer_overflow +print +print "Days it will take for a 32-bit system to timeout" +max_value_32 = pow(2, 32) +print(max_value_32/1000/seconds_in_a_day) + +# 5. How many days does it take for a 64-bit system to timeout, if it has a bug with integer overflow? +# The Binary Register Width of a processor determines the range of values that can be represented. +# The maximum representable value for a 32-bit system will be 2^64-1 +# When an arithmetic operation (in this case the increment of a millisecond in the time) +# produces a result larger than the above we will have an `integer overflow` +# To calculate the days it will take to reach that situation for a 64-bit system +# we need to convert 2^64 milliseconds in days by dividing by 1000s then 60s then 60m 24h +# source https://en.wikipedia.org/wiki/Integer_overflow +print +print "Days it will take for a 64-bit system to timeout" +max_value_64 = pow(2, 64) +print(max_value_64/1000/seconds_in_a_day) + +# 7. Calculate your age accurately based on your birthday +# https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds +# https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting +print +delta = datetime.now() - datetime(1986, 12, 8, 18, 45) +print "My age is %d seconds" % delta.total_seconds() \ No newline at end of file From 8b2ddcc4a6deb009902ed85e31f21263900cc826 Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Tue, 17 Jul 2018 15:39:26 +0100 Subject: [PATCH 05/12] improved readability --- .../soc-wk1-cert-cristina-tarantino.py | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py index 472d8212..c79f0e59 100644 --- a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py +++ b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py @@ -2,9 +2,17 @@ days_in_year = 365 days_in_year_leap = 365.2422 + +# 60 minutes/hour * 24 hours/day +minutes_in_a_day = 60 * 24 + +# 60 seconds/minute * 60 minutes/hour * 24 hours/day seconds_in_a_day = 60*60*24 -seconds_in_a_year = seconds_in_a_day*days_in_year -seconds_in_a_year_leap = seconds_in_a_day*days_in_year_leap + +seconds_in_a_year = seconds_in_a_day * days_in_year +seconds_in_a_year_leap = seconds_in_a_day * days_in_year_leap + +seconds_in_milliseconds = 1000 # 1. Hours in a year. How many hours are in a year? # a day has 24h and a year has 365 days @@ -12,39 +20,40 @@ # 1 common year = 365 days = (365 days) times (24 hours/day) = 8760 hours print print "Hours in a year:" -print(24*days_in_year) +print(24 * days_in_year) # 2. Minutes in a decade. How many minutes are in a decade? # 60 (minutes in 1 hour) times 24 (hours in a day) times 365 times 10 = 5256000 (Integer) print print "Minutes in a decade:" -print(60*24*days_in_year*10) +print(minutes_in_a_day * days_in_year * 10) # If we want to be more accurate though we should know that # a year is actually 365.2422 making the calculation = to 5259487.68 (Float) # source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day print print "Minutes in a decade considering leaps:" -print(60*24*days_in_year_leap*10) +print(minutes_in_a_day * days_in_year_leap * 10) # 3. Your age in seconds. How many seconds old are you? print print "My age in seconds:" -print(seconds_in_a_year_leap*32) +my_age = 32 +print(seconds_in_a_year_leap * my_age) # 4. Andreea is 48618000 seconds old. Calculate her age andreea_seconds_old = 48618000 print print "Andreea's age:" -print(andreea_seconds_old/seconds_in_a_year_leap) +print(andreea_seconds_old / seconds_in_a_year_leap) # https://github.com/1millionwomentotech/toolkitten/issues/35 print print "Andreea's corrected age:" -print(andreea_seconds_old/seconds_in_a_year_leap*24) +print(andreea_seconds_old / seconds_in_a_year_leap * 24) # 5. How many days does it take for a 32-bit system to timeout, if it has a bug with integer overflow? # The Binary Register Width of a processor determines the range of values that can be represented. @@ -57,7 +66,7 @@ print print "Days it will take for a 32-bit system to timeout" max_value_32 = pow(2, 32) -print(max_value_32/1000/seconds_in_a_day) +print(max_value_32 / seconds_in_milliseconds / seconds_in_a_day) # 5. How many days does it take for a 64-bit system to timeout, if it has a bug with integer overflow? # The Binary Register Width of a processor determines the range of values that can be represented. @@ -70,7 +79,7 @@ print print "Days it will take for a 64-bit system to timeout" max_value_64 = pow(2, 64) -print(max_value_64/1000/seconds_in_a_day) +print(max_value_64 / seconds_in_milliseconds / seconds_in_a_day) # 7. Calculate your age accurately based on your birthday # https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds From cc8573798def0ce55095d27f024682c0d3f9a619 Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Tue, 17 Jul 2018 15:48:45 +0100 Subject: [PATCH 06/12] added more comments to my age calculation --- summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py | 1 + 1 file changed, 1 insertion(+) diff --git a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py index c79f0e59..5963e7bd 100644 --- a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py +++ b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py @@ -41,6 +41,7 @@ print print "My age in seconds:" my_age = 32 +# 60 seconds/minutes * 60 minutes/hours * 24 hours/days * 365.2422 days/year * 32 year print(seconds_in_a_year_leap * my_age) From ccc0e0242a30573daadb042f32559bf94a81f095 Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Thu, 19 Jul 2018 10:06:37 +0100 Subject: [PATCH 07/12] string concatenations, int conversion to string, use of escape --- .../soc-wk1-cert-cristina-tarantino.py | 49 +++++++------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py index 5963e7bd..5ce148e8 100644 --- a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py +++ b/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py @@ -1,6 +1,8 @@ from datetime import datetime days_in_year = 365 + +# year leap. Source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day days_in_year_leap = 365.2422 # 60 minutes/hour * 24 hours/day @@ -18,43 +20,29 @@ # a day has 24h and a year has 365 days # therefore # 1 common year = 365 days = (365 days) times (24 hours/day) = 8760 hours -print -print "Hours in a year:" -print(24 * days_in_year) - +print ("\nHours in a year: " + str(24 * days_in_year)) # 2. Minutes in a decade. How many minutes are in a decade? # 60 (minutes in 1 hour) times 24 (hours in a day) times 365 times 10 = 5256000 (Integer) -print -print "Minutes in a decade:" -print(minutes_in_a_day * days_in_year * 10) +print ("\nMinutes in a decade: " + str(minutes_in_a_day * days_in_year * 10)) # If we want to be more accurate though we should know that # a year is actually 365.2422 making the calculation = to 5259487.68 (Float) # source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day -print -print "Minutes in a decade considering leaps:" -print(minutes_in_a_day * days_in_year_leap * 10) - +print ("\nMinutes in a decade considering leaps: " + str(minutes_in_a_day * days_in_year_leap * 10)) # 3. Your age in seconds. How many seconds old are you? -print -print "My age in seconds:" -my_age = 32 # 60 seconds/minutes * 60 minutes/hours * 24 hours/days * 365.2422 days/year * 32 year -print(seconds_in_a_year_leap * my_age) - +my_age = 32 +print ("\nMy age in seconds: " + str(seconds_in_a_year_leap * my_age)) # 4. Andreea is 48618000 seconds old. Calculate her age +# example showing use of escape characters andreea_seconds_old = 48618000 -print -print "Andreea's age:" -print(andreea_seconds_old / seconds_in_a_year_leap) +print ('\nAndreea\'s age: ' + str(andreea_seconds_old / seconds_in_a_year_leap)) # https://github.com/1millionwomentotech/toolkitten/issues/35 -print -print "Andreea's corrected age:" -print(andreea_seconds_old / seconds_in_a_year_leap * 24) +print ("\nAndreea's corrected age: " + str(andreea_seconds_old / seconds_in_a_year_leap * 24)) # 5. How many days does it take for a 32-bit system to timeout, if it has a bug with integer overflow? # The Binary Register Width of a processor determines the range of values that can be represented. @@ -64,10 +52,8 @@ # To calculate the days it will take to reach that situation for a 32-bit system # we need to convert 2^32 milliseconds in days by dividing by 1000s then 60s then 60m 24h # source https://en.wikipedia.org/wiki/Integer_overflow -print -print "Days it will take for a 32-bit system to timeout" max_value_32 = pow(2, 32) -print(max_value_32 / seconds_in_milliseconds / seconds_in_a_day) +print ("\nDays it will take for a 32-bit system to timeout: " + str(max_value_32 / seconds_in_milliseconds / seconds_in_a_day)) # 5. How many days does it take for a 64-bit system to timeout, if it has a bug with integer overflow? # The Binary Register Width of a processor determines the range of values that can be represented. @@ -77,14 +63,17 @@ # To calculate the days it will take to reach that situation for a 64-bit system # we need to convert 2^64 milliseconds in days by dividing by 1000s then 60s then 60m 24h # source https://en.wikipedia.org/wiki/Integer_overflow -print -print "Days it will take for a 64-bit system to timeout" max_value_64 = pow(2, 64) -print(max_value_64 / seconds_in_milliseconds / seconds_in_a_day) +print ("\nDays it will take for a 64-bit system to timeout: " + str(max_value_64 / seconds_in_milliseconds / seconds_in_a_day)) # 7. Calculate your age accurately based on your birthday # https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds # https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting -print +# example showing %s string variable delta = datetime.now() - datetime(1986, 12, 8, 18, 45) -print "My age is %d seconds" % delta.total_seconds() \ No newline at end of file +print ("\nMy age is %d seconds" % delta.total_seconds()) + +# Full name greeting. Write a program that asks for a person's first name, then middle, and then last. +# Finally, it should greet the person using their full name. +var = input("Please enter something: ") +print("You entered " + str(var)) \ No newline at end of file From 27cdc8313b34cf9440a08253a06138a98a973df4 Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Thu, 19 Jul 2018 14:01:10 +0100 Subject: [PATCH 08/12] added day 3 exercises --- .gitignore | 1 + .../soc-wk1-cert-cristina-tarantino.py | 55 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) rename summer-of-code/week-01/{ => wk1-homework-submission}/soc-wk1-cert-cristina-tarantino.py (57%) diff --git a/.gitignore b/.gitignore index 0088af8e..f86f7665 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ typings/ # IDE .idea +venv diff --git a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py b/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py similarity index 57% rename from summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py rename to summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py index 5ce148e8..5e19d09d 100644 --- a/summer-of-code/week-01/soc-wk1-cert-cristina-tarantino.py +++ b/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py @@ -9,7 +9,7 @@ minutes_in_a_day = 60 * 24 # 60 seconds/minute * 60 minutes/hour * 24 hours/day -seconds_in_a_day = 60*60*24 +seconds_in_a_day = 60 * 60 * 24 seconds_in_a_year = seconds_in_a_day * days_in_year seconds_in_a_year_leap = seconds_in_a_day * days_in_year_leap @@ -20,29 +20,29 @@ # a day has 24h and a year has 365 days # therefore # 1 common year = 365 days = (365 days) times (24 hours/day) = 8760 hours -print ("\nHours in a year: " + str(24 * days_in_year)) +print("\nHours in a year: " + str(24 * days_in_year)) # 2. Minutes in a decade. How many minutes are in a decade? # 60 (minutes in 1 hour) times 24 (hours in a day) times 365 times 10 = 5256000 (Integer) -print ("\nMinutes in a decade: " + str(minutes_in_a_day * days_in_year * 10)) +print("\nMinutes in a decade: " + str(minutes_in_a_day * days_in_year * 10)) # If we want to be more accurate though we should know that # a year is actually 365.2422 making the calculation = to 5259487.68 (Float) # source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day -print ("\nMinutes in a decade considering leaps: " + str(minutes_in_a_day * days_in_year_leap * 10)) +print("\nMinutes in a decade considering leaps: " + str(minutes_in_a_day * days_in_year_leap * 10)) # 3. Your age in seconds. How many seconds old are you? # 60 seconds/minutes * 60 minutes/hours * 24 hours/days * 365.2422 days/year * 32 year my_age = 32 -print ("\nMy age in seconds: " + str(seconds_in_a_year_leap * my_age)) +print("\nMy age in seconds: " + str(seconds_in_a_year_leap * my_age)) # 4. Andreea is 48618000 seconds old. Calculate her age # example showing use of escape characters andreea_seconds_old = 48618000 -print ('\nAndreea\'s age: ' + str(andreea_seconds_old / seconds_in_a_year_leap)) +print('\nAndreea\'s age: ' + str(andreea_seconds_old / seconds_in_a_year_leap)) # https://github.com/1millionwomentotech/toolkitten/issues/35 -print ("\nAndreea's corrected age: " + str(andreea_seconds_old / seconds_in_a_year_leap * 24)) +print("\nAndreea's corrected age: " + str(andreea_seconds_old / seconds_in_a_year_leap * 24)) # 5. How many days does it take for a 32-bit system to timeout, if it has a bug with integer overflow? # The Binary Register Width of a processor determines the range of values that can be represented. @@ -53,9 +53,10 @@ # we need to convert 2^32 milliseconds in days by dividing by 1000s then 60s then 60m 24h # source https://en.wikipedia.org/wiki/Integer_overflow max_value_32 = pow(2, 32) -print ("\nDays it will take for a 32-bit system to timeout: " + str(max_value_32 / seconds_in_milliseconds / seconds_in_a_day)) +print("\nDays it will take for a 32-bit system to timeout: " + str( + max_value_32 / seconds_in_milliseconds / seconds_in_a_day)) -# 5. How many days does it take for a 64-bit system to timeout, if it has a bug with integer overflow? +# 6. How many days does it take for a 64-bit system to timeout, if it has a bug with integer overflow? # The Binary Register Width of a processor determines the range of values that can be represented. # The maximum representable value for a 32-bit system will be 2^64-1 # When an arithmetic operation (in this case the increment of a millisecond in the time) @@ -64,16 +65,38 @@ # we need to convert 2^64 milliseconds in days by dividing by 1000s then 60s then 60m 24h # source https://en.wikipedia.org/wiki/Integer_overflow max_value_64 = pow(2, 64) -print ("\nDays it will take for a 64-bit system to timeout: " + str(max_value_64 / seconds_in_milliseconds / seconds_in_a_day)) +print("\nDays it will take for a 64-bit system to timeout: " + str( + max_value_64 / seconds_in_milliseconds / seconds_in_a_day)) # 7. Calculate your age accurately based on your birthday # https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds # https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting # example showing %s string variable delta = datetime.now() - datetime(1986, 12, 8, 18, 45) -print ("\nMy age is %d seconds" % delta.total_seconds()) - -# Full name greeting. Write a program that asks for a person's first name, then middle, and then last. -# Finally, it should greet the person using their full name. -var = input("Please enter something: ") -print("You entered " + str(var)) \ No newline at end of file +print("\nMy age is %d seconds" % delta.total_seconds()) + +# 8. Full name greeting. Write a program that asks for a person's first name, then middle, and then last. +# Finally, it should greet the person using their full name. +name = input("\nCould you please type your first name: ") +middle_name = input("Could you please type your middle name: ") +last_name = input("Could you please type your last name: ") +print("\nHello %s %s %s! A really warm welcome to you!" % (name, middle_name, last_name)) + +# 9. Bigger, better favorite number. Write a program that asks for a person's favorite number. +# Have your program add 1 to the number, and then suggest the result as a bigger and better favorite number. +while True: + try: + favorite_number = int(input("\n" + name + " could you please type your favourite number? ")) + except ValueError: + print("That wasn't a number!") + continue + else: + big_favorite_number = str(favorite_number + 1) + print("I have for you a bigger and better favourite number. What about a nice %s." % big_favorite_number) + break + + +# 10. Angry boss. Write an angry boss program that rudely asks what you want. +# Whatever you answer, the angry boss should yell it back to you and then fire you. +answer = input("\n" + name + " what the hell do you want? ") +print(("whaddaya mean \"" + answer + "\"?!? you're fired!!").upper()) From 885178d8f4d4142e09a30b9a20063cd6a44d7873 Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Thu, 19 Jul 2018 14:22:18 +0100 Subject: [PATCH 09/12] added some spaces and gitignore update --- .gitignore | 3 +++ .../wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index f86f7665..446bde9b 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,9 @@ typings/ # next.js build output .next +# mac finder cache +.DS_Store + # IDE .idea venv diff --git a/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py b/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py index 5e19d09d..6136634e 100644 --- a/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py +++ b/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py @@ -75,6 +75,7 @@ delta = datetime.now() - datetime(1986, 12, 8, 18, 45) print("\nMy age is %d seconds" % delta.total_seconds()) + # 8. Full name greeting. Write a program that asks for a person's first name, then middle, and then last. # Finally, it should greet the person using their full name. name = input("\nCould you please type your first name: ") @@ -82,6 +83,7 @@ last_name = input("Could you please type your last name: ") print("\nHello %s %s %s! A really warm welcome to you!" % (name, middle_name, last_name)) + # 9. Bigger, better favorite number. Write a program that asks for a person's favorite number. # Have your program add 1 to the number, and then suggest the result as a bigger and better favorite number. while True: From 5a8d48351035938c339bf5b6ca12ddfe389f2adf Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Thu, 19 Jul 2018 14:31:01 +0100 Subject: [PATCH 10/12] Fixed typo in `day3.md`. --- summer-of-code/week-01/day3.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/summer-of-code/week-01/day3.md b/summer-of-code/week-01/day3.md index 9af658d5..dc343d9b 100644 --- a/summer-of-code/week-01/day3.md +++ b/summer-of-code/week-01/day3.md @@ -65,9 +65,9 @@ Let’s look at what these methods do (and don’t do) a little more closely: ``` var1 = 2 -var2 = ​'5'​ +var2 = '5' print(str(var1) + var2) -print(var1 + int(var2) +print(var1 + int(var2)) print(var1) print(var2) 25 From 27f98bd6799612b28557c8b8e4474463f5e88b7f Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Thu, 19 Jul 2018 14:47:36 +0100 Subject: [PATCH 11/12] removed unwanted changes --- .gitignore | 9 +- summer-of-code/week-01/calc.py | 12 +- .../soc-wk1-cert-cristina-tarantino.py | 104 ------------------ 3 files changed, 11 insertions(+), 114 deletions(-) delete mode 100644 summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py diff --git a/.gitignore b/.gitignore index 446bde9b..8fdf499e 100644 --- a/.gitignore +++ b/.gitignore @@ -58,11 +58,4 @@ typings/ .env # next.js build output -.next - -# mac finder cache -.DS_Store - -# IDE -.idea -venv +.next \ No newline at end of file diff --git a/summer-of-code/week-01/calc.py b/summer-of-code/week-01/calc.py index 457fb18d..a97545e0 100644 --- a/summer-of-code/week-01/calc.py +++ b/summer-of-code/week-01/calc.py @@ -1,3 +1,5 @@ +# calculator + # print(1+2) # print(3) @@ -28,7 +30,7 @@ # print('2 * 5') # print('12' + 12) -# print('12' + str(12)) +#print('12' + str(12)) # print('2' * '5') @@ -38,4 +40,10 @@ print('You\'re swell!') print('backslash at the end of a string: \\') print('up\\down') -print('up\down') \ No newline at end of file +print('up\down') + + + + + + diff --git a/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py b/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py deleted file mode 100644 index 6136634e..00000000 --- a/summer-of-code/week-01/wk1-homework-submission/soc-wk1-cert-cristina-tarantino.py +++ /dev/null @@ -1,104 +0,0 @@ -from datetime import datetime - -days_in_year = 365 - -# year leap. Source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day -days_in_year_leap = 365.2422 - -# 60 minutes/hour * 24 hours/day -minutes_in_a_day = 60 * 24 - -# 60 seconds/minute * 60 minutes/hour * 24 hours/day -seconds_in_a_day = 60 * 60 * 24 - -seconds_in_a_year = seconds_in_a_day * days_in_year -seconds_in_a_year_leap = seconds_in_a_day * days_in_year_leap - -seconds_in_milliseconds = 1000 - -# 1. Hours in a year. How many hours are in a year? -# a day has 24h and a year has 365 days -# therefore -# 1 common year = 365 days = (365 days) times (24 hours/day) = 8760 hours -print("\nHours in a year: " + str(24 * days_in_year)) - -# 2. Minutes in a decade. How many minutes are in a decade? -# 60 (minutes in 1 hour) times 24 (hours in a day) times 365 times 10 = 5256000 (Integer) -print("\nMinutes in a decade: " + str(minutes_in_a_day * days_in_year * 10)) - -# If we want to be more accurate though we should know that -# a year is actually 365.2422 making the calculation = to 5259487.68 (Float) -# source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day -print("\nMinutes in a decade considering leaps: " + str(minutes_in_a_day * days_in_year_leap * 10)) - -# 3. Your age in seconds. How many seconds old are you? -# 60 seconds/minutes * 60 minutes/hours * 24 hours/days * 365.2422 days/year * 32 year -my_age = 32 -print("\nMy age in seconds: " + str(seconds_in_a_year_leap * my_age)) - -# 4. Andreea is 48618000 seconds old. Calculate her age -# example showing use of escape characters -andreea_seconds_old = 48618000 -print('\nAndreea\'s age: ' + str(andreea_seconds_old / seconds_in_a_year_leap)) - -# https://github.com/1millionwomentotech/toolkitten/issues/35 -print("\nAndreea's corrected age: " + str(andreea_seconds_old / seconds_in_a_year_leap * 24)) - -# 5. How many days does it take for a 32-bit system to timeout, if it has a bug with integer overflow? -# The Binary Register Width of a processor determines the range of values that can be represented. -# The maximum representable value for a 32-bit system will be 2^32-1 -# When an arithmetic operation (in this case the increment of a millisecond in the time) -# produces a result larger than the above we will have an `integer overflow` -# To calculate the days it will take to reach that situation for a 32-bit system -# we need to convert 2^32 milliseconds in days by dividing by 1000s then 60s then 60m 24h -# source https://en.wikipedia.org/wiki/Integer_overflow -max_value_32 = pow(2, 32) -print("\nDays it will take for a 32-bit system to timeout: " + str( - max_value_32 / seconds_in_milliseconds / seconds_in_a_day)) - -# 6. How many days does it take for a 64-bit system to timeout, if it has a bug with integer overflow? -# The Binary Register Width of a processor determines the range of values that can be represented. -# The maximum representable value for a 32-bit system will be 2^64-1 -# When an arithmetic operation (in this case the increment of a millisecond in the time) -# produces a result larger than the above we will have an `integer overflow` -# To calculate the days it will take to reach that situation for a 64-bit system -# we need to convert 2^64 milliseconds in days by dividing by 1000s then 60s then 60m 24h -# source https://en.wikipedia.org/wiki/Integer_overflow -max_value_64 = pow(2, 64) -print("\nDays it will take for a 64-bit system to timeout: " + str( - max_value_64 / seconds_in_milliseconds / seconds_in_a_day)) - -# 7. Calculate your age accurately based on your birthday -# https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds -# https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting -# example showing %s string variable -delta = datetime.now() - datetime(1986, 12, 8, 18, 45) -print("\nMy age is %d seconds" % delta.total_seconds()) - - -# 8. Full name greeting. Write a program that asks for a person's first name, then middle, and then last. -# Finally, it should greet the person using their full name. -name = input("\nCould you please type your first name: ") -middle_name = input("Could you please type your middle name: ") -last_name = input("Could you please type your last name: ") -print("\nHello %s %s %s! A really warm welcome to you!" % (name, middle_name, last_name)) - - -# 9. Bigger, better favorite number. Write a program that asks for a person's favorite number. -# Have your program add 1 to the number, and then suggest the result as a bigger and better favorite number. -while True: - try: - favorite_number = int(input("\n" + name + " could you please type your favourite number? ")) - except ValueError: - print("That wasn't a number!") - continue - else: - big_favorite_number = str(favorite_number + 1) - print("I have for you a bigger and better favourite number. What about a nice %s." % big_favorite_number) - break - - -# 10. Angry boss. Write an angry boss program that rudely asks what you want. -# Whatever you answer, the angry boss should yell it back to you and then fire you. -answer = input("\n" + name + " what the hell do you want? ") -print(("whaddaya mean \"" + answer + "\"?!? you're fired!!").upper()) From 7bd19c72ea17b5806270140540f87d98f7895f11 Mon Sep 17 00:00:00 2001 From: Cristina Tarantino Date: Thu, 19 Jul 2018 14:51:53 +0100 Subject: [PATCH 12/12] added spaces at the bottom of files --- .gitignore | 2 +- summer-of-code/week-01/calc.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8fdf499e..ad46b308 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,4 @@ typings/ .env # next.js build output -.next \ No newline at end of file +.next diff --git a/summer-of-code/week-01/calc.py b/summer-of-code/week-01/calc.py index a97545e0..e6cdde25 100644 --- a/summer-of-code/week-01/calc.py +++ b/summer-of-code/week-01/calc.py @@ -47,3 +47,4 @@ +