├── CS50 AI ├── attention │ └── mask.py ├── crosswords │ └── generate.py ├── degrees │ └── degrees.py ├── heredity │ └── heredity.py ├── knights │ └── puzzle.py ├── minesweeper │ └── minesweeper.py ├── nim │ └── nim.py ├── pagerank │ └── pagerank.py ├── shopping │ └── shopping.py ├── tictactoe │ └── tictactoe.py └── traffic │ └── traffic.py ├── CS50 Games ├── Pong │ ├── main.lua │ └── push.lua └── bird │ ├── Bird.lua │ ├── Pipe.lua │ ├── PipePair.lua │ ├── StateMachine.lua │ ├── background.png │ ├── bird.png │ ├── class.lua │ ├── cooper.png │ ├── explosion.wav │ ├── flappy.ttf │ ├── font.ttf │ ├── gold.png │ ├── ground.png │ ├── hurt.wav │ ├── jump.wav │ ├── main.lua │ ├── marios_way.mp3 │ ├── pause.png │ ├── pipe.png │ ├── push.lua │ ├── score.wav │ ├── silver.png │ └── states │ ├── BaseState.lua │ ├── CountdownState.lua │ ├── PlayState.lua │ ├── ScoreState.lua │ └── TitleScreenState.lua ├── CS50 Python ├── FinalProject │ ├── new_students.csv │ └── project.py ├── PSET0 │ ├── einstein │ │ └── einstein.py │ ├── faces │ │ └── faces.py │ ├── indoor │ │ └── indoor.py │ ├── playback │ │ └── playback.py │ └── tip │ │ └── tip.py ├── Pset1 │ ├── bank │ │ └── bank.py │ ├── deep │ │ └── deep.py │ ├── extensions │ │ └── extensions.py │ ├── interpreter │ │ └── interpreter.py │ └── meal │ │ └── meal.py ├── Pset2 │ ├── camel │ │ └── camel.py │ ├── coke │ │ └── coke.py │ ├── nutrition │ │ └── nutrition.py │ ├── plates │ │ └── plates.py │ └── twttr │ │ └── twttr.py ├── Pset3 │ ├── fuel │ │ └── fuel.py │ ├── grocery │ │ └── grocery.py │ ├── outdated │ │ └── outdated.py │ └── taqueria │ │ └── taqueria.py ├── Pset4 │ ├── adieu │ │ └── adieu.py │ ├── bitcoin │ │ └── bitcoin.py │ ├── emojize │ │ └── emojize.py │ ├── figlet │ │ └── figlet.py │ ├── game │ │ └── game.py │ └── professor │ │ └── professor.py ├── Pset5 │ ├── test_bank │ │ ├── bank.py │ │ └── test_bank.py │ ├── test_fuel │ │ ├── fuel.py │ │ └── test_fuel.py │ ├── test_plates │ │ ├── plates.py │ │ └── test_plates.py │ └── test_twttr │ │ ├── test_twttr.py │ │ └── twttr.py ├── Pset6 │ ├── lines │ │ └── lines.py │ ├── pizza │ │ └── pizza.py │ ├── scourgify │ │ └── scourgify.py │ └── shirt │ │ └── shirt.py ├── Pset7 │ ├── numb3rs │ │ ├── numb3rs.py │ │ └── test_numb3rs.py │ ├── response │ │ └── response.py │ ├── um │ │ ├── test_um.py │ │ └── um.py │ ├── watch │ │ └── watch.py │ └── working │ │ ├── test_working.py │ │ └── working.py └── Pset8 │ ├── jar │ ├── jar.py │ └── test_jar.py │ ├── seasons │ ├── seasons.py │ └── test_seasons.py │ └── shirtificate │ └── shirtificate.py ├── CS50 SQL ├── project │ ├── queries.sql │ └── schema.sql ├── week 0 │ ├── cyberchase │ │ ├── 1.sql │ │ ├── 10.sql │ │ ├── 11.sql │ │ ├── 12.sql │ │ ├── 13.sql │ │ ├── 2.sql │ │ ├── 3.sql │ │ ├── 4.sql │ │ ├── 5.sql │ │ ├── 6.sql │ │ ├── 7.sql │ │ ├── 8.sql │ │ └── 9.sql │ ├── normals │ │ ├── 1.sql │ │ ├── 10.sql │ │ ├── 2.sql │ │ ├── 3.sql │ │ ├── 4.sql │ │ ├── 5.sql │ │ ├── 6.sql │ │ ├── 7.sql │ │ ├── 8.sql │ │ └── 9.sql │ ├── players │ │ ├── 1.sql │ │ ├── 10.sql │ │ ├── 2.sql │ │ ├── 3.sql │ │ ├── 4.sql │ │ ├── 5.sql │ │ ├── 6.sql │ │ ├── 7.sql │ │ ├── 8.sql │ │ └── 9.sql │ └── views │ │ ├── 1.sql │ │ ├── 10.sql │ │ ├── 2.sql │ │ ├── 3.sql │ │ ├── 4.sql │ │ ├── 5.sql │ │ ├── 6.sql │ │ ├── 7.sql │ │ ├── 8.sql │ │ └── 9.sql ├── week1 │ ├── dese │ │ ├── 1.sql │ │ ├── 10.sql │ │ ├── 11.sql │ │ ├── 12.sql │ │ ├── 13.sql │ │ ├── 2.sql │ │ ├── 3.sql │ │ ├── 4.sql │ │ ├── 5.sql │ │ ├── 6.sql │ │ ├── 7.sql │ │ ├── 8.sql │ │ └── 9.sql │ ├── moneyball │ │ ├── 1.sql │ │ ├── 10.sql │ │ ├── 11.sql │ │ ├── 12.sql │ │ ├── 2.sql │ │ ├── 3.sql │ │ ├── 4.sql │ │ ├── 5.sql │ │ ├── 6.sql │ │ ├── 7.sql │ │ ├── 8.sql │ │ └── 9.sql │ └── packages │ │ ├── answers.txt │ │ └── log.sql ├── week2 │ ├── atl │ │ └── schema.sql │ ├── connect │ │ └── schema.sql │ └── donuts │ │ └── schema.sql ├── week3 │ ├── dont-panic │ │ └── hack.sql │ └── meteorites │ │ └── import.sql ├── week4 │ ├── bnb │ │ ├── available.sql │ │ ├── frequently_reviewed.sql │ │ ├── june_vacancies.sql │ │ ├── no_descriptions.sql │ │ └── one_bedrooms.sql │ ├── census │ │ ├── by_district.sql │ │ ├── most_populated.sql │ │ ├── rural.sql │ │ └── total.sql │ └── private │ │ └── private.sql ├── week5 │ └── harvard │ │ └── harvard.sql └── week6 │ ├── dont-panic-java │ └── Hack.java │ ├── dont-panic-python │ └── hack.py │ └── sentimental-connect │ └── schema.sql ├── CS50 Web ├── commerce │ ├── auctions │ │ ├── admin.py │ │ ├── apps.py │ │ ├── models.py │ │ ├── templates │ │ │ └── auctions │ │ │ │ ├── closed_listing.html │ │ │ │ ├── create_listing.html │ │ │ │ ├── index.html │ │ │ │ ├── layout.html │ │ │ │ ├── listing_page.html │ │ │ │ ├── login.html │ │ │ │ ├── register.html │ │ │ │ └── watchlist_page.html │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py │ └── manage.py ├── mail │ ├── README.md │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── models.py │ ├── static │ │ ├── inbox.js │ │ └── styles.css │ ├── templates │ │ └── mail │ │ │ └── inbox.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── network │ ├── admin.py │ ├── models.py │ ├── templates │ │ └── network │ │ │ ├── following.html │ │ │ ├── index.html │ │ │ ├── layout.html │ │ │ ├── login.html │ │ │ ├── profile.html │ │ │ └── register.html │ ├── urls.py │ └── views.py ├── search │ ├── advanced.css │ ├── advanced.html │ ├── google.png │ ├── googleimg.png │ ├── image.html │ ├── index.html │ ├── styles.css │ └── styles_image.css └── wiki │ ├── encyclopedia │ ├── admin.py │ ├── apps.py │ ├── models.py │ ├── templates │ │ ├── already_exist.html │ │ ├── edit.html │ │ ├── entry.html │ │ ├── index.html │ │ ├── layout.html │ │ ├── new.html │ │ ├── search.html │ │ └── wrong_entry.html │ ├── tests.py │ ├── urls.py │ ├── util.py │ └── views.py │ └── manage.py ├── CodingDors ├── 1_functions_and_variables │ ├── 10_convert_miles.py │ ├── 1_return_hello.py │ ├── 241_calc_bmi.py │ ├── 242_volume_of_cylinder.py │ ├── 243_convert_seconds.py │ ├── 244_calculate_area_of_circle.py │ ├── 245_calculate_average.py │ ├── 246_convert_fahrenheit_to_celsius.py │ ├── 247_convert_celsius_to_kelvin.py │ ├── 250_convert_lb_to_kg.py │ ├── 279_return_two.py │ ├── 280_return_n.py │ ├── 2_return_person_details.py │ ├── 3_title_movie.py │ ├── 4_upper_movie.py │ ├── 5_lower_movie.py │ ├── 6_remove_whitespace.py │ ├── 7_replace_words.py │ ├── 8_round_floats.py │ └── 9_remove_letter_g.py ├── 2_strings │ ├── 121_first_character.py │ ├── 122_second_character.py │ ├── 123_last_character.py │ ├── 124_concatenate_strings.py │ ├── 125_repeat_string.py │ ├── 126_uppercase_first.py │ ├── 127_lowercase_first.py │ ├── 130_replace_char.py │ ├── 131_remove_char.py │ ├── 134_string_length.py │ ├── 135_substring.py │ ├── 137_remove_whitespace_str.py │ ├── 18_missing_chars.py │ ├── 19_front_back.py │ ├── 251_birthdate.py │ ├── 252_formatted_time.py │ ├── 253_full_name.py │ ├── 254_year_day.py │ ├── 255_initials.py │ └── 256_get_extension.py ├── 3_conditionals │ ├── 101_is_even.py │ ├── 102_is_positive.py │ ├── 103_is_divisible.py │ ├── 104_maximum.py │ ├── 105_minimum.py │ ├── 106_absolute_value.py │ ├── 107_greater_number.py │ ├── 108_is_negative.py │ ├── 109_is_odd.py │ ├── 110_is_leap_year.py │ ├── 111_is_vowel.py │ ├── 112_is_consonant.py │ ├── 113_is_uppercase.py │ ├── 114_is_lowercase.py │ ├── 115_is_same_letter.py │ ├── 116_is_digit.py │ ├── 117_is_alphabetic.py │ ├── 118_is_alphanumeric.py │ ├── 119_is_greater_or_equal.py │ └── 120_is_smaller_or_equal.py ├── 4_conditionals2 │ ├── 11_should_take_umbrella.py │ ├── 12_team_trouble.py │ ├── 13_sum_or_half_sum.py │ ├── 14_absolute_difference.py │ ├── 15_dog_trouble.py │ ├── 16_near_ten.py │ ├── 17_hi_string.py │ ├── 181_caught_speeding.py │ ├── 183_alarm_clock.py │ ├── 184_love_six.py │ ├── 185_in_one_to_ten.py │ ├── 186_near_ten_bool.py │ ├── 187_teen_sum.py │ ├── 188_answer_cell.py │ ├── 189_tea_party.py │ ├── 190_fizz_string.py │ ├── 194_max_mod5.py │ ├── 20_front5.py │ ├── 277_grade_convertor.py │ └── 278_check_temperature.py ├── 5_lists │ ├── 257_first_element.py │ ├── 258_second_element.py │ ├── 259_last_element.py │ ├── 260_list_length.py │ ├── 261_concatenate_lists.py │ ├── 262_repeat_list.py │ ├── 263_front_back_list.py │ ├── 264_first_element_is_greater.py │ ├── 265_first_element_is_smaller.py │ ├── 266_first_last9.py │ ├── 267_same_value.py │ ├── 268_common_element.py │ ├── 269_sum_all.py │ ├── 270_new_list.py │ ├── 271_rotate_right.py │ ├── 272_reverse_list.py │ ├── 273_min_end.py │ ├── 274_compare_lists.py │ ├── 275_make_ends.py │ └── 276_even_list.py ├── 6_loops │ ├── 21_return_quarters.py │ ├── 22_sum_sequence.py │ ├── 23_count_digits.py │ ├── 24_sum_digits.py │ ├── 25_sum_every_other_digit.py │ ├── 26_sum_every_other_digit_two.py │ ├── 294_sum_to_n_even.py │ ├── 295_sum_odd_to_n_forloop.py │ ├── 296_sum_even_number_while.py │ ├── 297_sum_to_n_odd_while.py │ ├── 298_sum_reverse_n_for.py │ ├── 299_sum_reverse_n_while.py │ ├── 300_sum_reverse_n_even_for.py │ ├── 301_sum_reverse_n_even_while.py │ ├── 302_sum_reverse_n_odd_while.py │ ├── 303_sum_reverse_n_odd_for.py │ ├── 304_sum_one_to_n_step.py │ ├── 305_sum_one_to_n_step_while.py │ ├── 83_sum_one_to_n.py │ └── 87_sum_one_to_n_while.py ├── 7_loops_in_strings │ ├── 128_count_vowels_str.py │ ├── 129_count_consonants_str.py │ ├── 132_find_char.py │ ├── 133_count_char.py │ ├── 136_swap_case.py │ ├── 138_split_string.py │ ├── 140_reverse_string.py │ ├── 281_count_lower_letters.py │ ├── 282_extract_uppercase.py │ ├── 283_find_uppercase_position.py │ ├── 284_replace_a_with_four.py │ ├── 285_reverse_swap.py │ ├── 286_replace_upper.py │ ├── 287_contains_special_chars.py │ ├── 288_has_matching.py │ ├── 289_check_first_number.py │ ├── 290_valid_vanity_plate.py │ ├── 291_triple_char.py │ ├── 292_hi_ho.py │ └── 293_count_code_times.py ├── 8_loops_in_lists │ ├── 306_has_matching_list.py │ ├── 307_check_first_number_list.py │ ├── 308_count_odds_list.py │ ├── 309_has33_list.py │ ├── 310_list456.py │ ├── 311_sum_matrix_elements.py │ ├── 312_has_letter_a_matrix.py │ ├── 313_sort_list.py │ ├── 81_print_to_n_for_loop.py │ ├── 82_print_to_n_even.py │ ├── 84_print_odd_to_n_forloop.py │ ├── 85_print_one_to_n_while.py │ ├── 86_print_even_number_while.py │ ├── 88_print_to_n_odd_while.py │ ├── 89_reverse_n_for.py │ ├── 90_reverse_n_while.py │ ├── 91_reverse_n_even_for.py │ ├── 92_reverse_n_even_while.py │ ├── 93_reverse_n_odd_while.py │ └── 94_reverse_n_odd_for.py ├── 9_dictionaries │ ├── 223_invert_dictionary.py │ ├── 224_capitalize_keys.py │ ├── 225_capitalize_values.py │ ├── 226_merge_dictionaries.py │ ├── 227_filter_by_value.py │ ├── 228_keys_of_max_value.py │ ├── 229_common_keys.py │ ├── 230_sum_values_dict.py │ ├── 231_sorted_keys.py │ ├── 233_dictionary_size.py │ ├── 234_remove_key.py │ ├── 235_square_values.py │ ├── 236_update_value.py │ ├── 237_dict_intersection.py │ ├── 238_count_values.py │ ├── 239_nested_value.py │ ├── 30_find_person.py │ ├── 314_create_dictionary.py │ ├── 315_add_element_dictionary.py │ └── 316_return_value.py └── Solutions │ ├── 1_functions_and_variables_solutions.py │ ├── 2_strings_solutions.py │ ├── 3_conditionals_solutions.py │ ├── 4_conditionals2_solutions.py │ ├── 5_lists_solutions.py │ ├── 6_loops_solutions.py │ ├── 7_loops_in_strings_solutions.py │ ├── 8_loops_in_lists_solutions.py │ └── 9_dictionaries_solutions.py ├── Labs ├── lab1.c ├── lab2.c ├── lab3.txt ├── lab4.c ├── lab4 │ └── smiley │ │ └── helpers.c ├── lab5.c ├── lab6.py ├── lab7 │ ├── 1.sql │ ├── 2.sql │ ├── 3.sql │ ├── 4.sql │ ├── 5.sql │ ├── 6.sql │ ├── 7.sql │ └── 8.sql ├── lab8 │ └── index.html └── lab9 │ ├── application.py │ └── index.html ├── Practice Problems ├── Week1 │ ├── WEEK 1 PRACTICE PROBLEMS.pdf │ ├── debug │ │ └── debug.c │ ├── half │ │ └── half.c │ └── prime │ │ └── prime.c ├── Week2 │ ├── WEEK 2 PRACTICE PROBLEMS.pdf │ ├── hours │ │ └── hours.c │ ├── no-v0w3ls │ │ └── no-v0w3ls.c │ └── password │ │ └── password.c ├── Week3 │ ├── atoi │ │ └── atoi.c │ ├── max │ │ └── max.c │ ├── snackbar │ │ └── snackbar.c │ └── temps │ │ └── temps.c ├── Week4 │ ├── bottomup │ │ └── bottomup.c │ └── license │ │ └── license.c ├── Week5 │ └── trie.c ├── Week6 │ ├── bank │ │ └── bank.py │ ├── figlet │ │ └── figlet.py │ ├── jar │ │ └── jar.py │ ├── seven-day-average │ │ └── seven-day-average.py │ └── taqueria │ │ └── taqueria.py ├── Week7 │ ├── favorites │ │ └── favorites.sql │ └── prophecy │ │ ├── schema.sql │ │ └── students.py ├── Week8 │ └── index.html └── Week9 │ ├── app.py │ └── templates │ ├── color.html │ ├── index.html │ └── layout.html ├── Problem Sets ├── FinalProject │ ├── app.py │ ├── project.db │ └── templates │ │ ├── apology.html │ │ ├── compose.html │ │ ├── email.html │ │ ├── index.html │ │ ├── layout.html │ │ ├── login.html │ │ ├── register.html │ │ ├── reply.html │ │ └── sent.html ├── pset1 │ ├── cash1.c │ ├── cash2.c │ ├── credit.c │ ├── mario-less.c │ ├── mario-more.c │ └── mario.c ├── pset2 │ ├── bulbs.c │ ├── caesar.c │ ├── readability.c │ ├── substitution.c │ └── wordle.c ├── pset3 │ ├── plurality.c │ ├── runoff.c │ └── tideman.c ├── pset4 │ ├── filters │ │ └── helpers.c │ ├── recover │ │ └── recover.c │ └── reverse │ │ └── reverse.c ├── pset5 │ └── speller │ │ └── dictionary.c ├── pset6 │ ├── credit.py │ ├── dna.py │ ├── hello.py │ ├── mario.py │ └── readability.py ├── pset7 │ ├── fiftyville │ │ ├── answers.txt │ │ └── log.sql │ ├── fiftyville2022 │ │ ├── answers.txt │ │ └── log.sql │ └── movies │ │ ├── 1.sql │ │ ├── 10.sql │ │ ├── 11.sql │ │ ├── 12.sql │ │ ├── 13.sql │ │ ├── 2.sql │ │ ├── 3.sql │ │ ├── 4.sql │ │ ├── 5.sql │ │ ├── 6.sql │ │ ├── 7.sql │ │ ├── 8.sql │ │ └── 9.sql ├── pset8 │ ├── coursedescription.html │ ├── index.html │ ├── lendas do cs50.png │ ├── styles.css │ ├── subreddit.html │ └── syllabus.html └── pset9 │ ├── application.py │ └── templates │ ├── apology.html │ ├── buy.html │ ├── history.html │ ├── index.html │ ├── layout.html │ ├── login.html │ ├── quote.html │ ├── quoted.html │ ├── register.html │ └── sell.html ├── README.md ├── The Odin Project ├── admin dashboard │ ├── images │ │ ├── avatar.png │ │ ├── avatar2.png │ │ ├── avatar3.png │ │ ├── avatar4.png │ │ └── images.txt │ ├── index.html │ └── styles.css ├── calculator │ ├── index.html │ ├── main.js │ └── styles.css ├── etch-a-sketch │ ├── index.html │ ├── main.js │ └── styles.css ├── landing page │ ├── index.html │ └── styles.css ├── library │ ├── books.css │ ├── books.html │ └── books.js ├── recipes │ ├── index.html │ ├── recipes │ │ ├── carbonara.html │ │ ├── lasagna.html │ │ └── pomdoro.html │ └── styles.css ├── rock paper scissors │ ├── index.html │ └── index.js └── sign up form │ ├── index.html │ ├── main.js │ └── style.css └── freeCodeCamp └── Responsive Web Design ├── Personal Portfolio Webpage ├── index.html └── styles.css ├── Product Landing Page ├── index.html └── styles.css ├── Survey Form └── index.html ├── Technical Documentation Page ├── index.html └── styles.css └── Tribute Page └── index.html /CS50 Games/bird/Pipe.lua: -------------------------------------------------------------------------------- 1 | Pipe = Class{} 2 | 3 | local PIPE_IMAGE = love.graphics.newImage('pipe.png') 4 | 5 | PIPE_SPEED = 60 6 | 7 | PIPE_HEIGHT = 288 8 | PIPE_WIDTH = 70 9 | 10 | function Pipe:init(orientation, y) 11 | self.x = VIRTUAL_WIDTH + 20 12 | 13 | self.y = y 14 | 15 | self.width = PIPE_IMAGE:getWidth() 16 | self.height = PIPE_HEIGHT 17 | 18 | self.orientation = orientation 19 | end 20 | 21 | function Pipe:update(dt) 22 | 23 | end 24 | 25 | function Pipe:render() 26 | love.graphics.draw(PIPE_IMAGE, self.x, 27 | (self.orientation == 'top' and self.y + PIPE_HEIGHT or self.y), 28 | 0, 1, self.orientation == 'top' and -1 or 1) 29 | end -------------------------------------------------------------------------------- /CS50 Games/bird/PipePair.lua: -------------------------------------------------------------------------------- 1 | PipePair = Class{} 2 | 3 | local GAP_HEIGHT = 90 4 | 5 | function PipePair:init(y) 6 | self.x = VIRTUAL_WIDTH + 32 7 | self.y = y 8 | 9 | self.pipes = { 10 | ['upper'] = Pipe('top', self.y), 11 | ['lower'] = Pipe('bottom', self.y + PIPE_HEIGHT + GAP_HEIGHT) 12 | } 13 | self.remove = false 14 | 15 | self.scored = false 16 | end 17 | 18 | function PipePair:update(dt) 19 | if self.x > -PIPE_WIDTH then 20 | self.x = self.x - PIPE_SPEED * dt 21 | self.pipes['lower'].x = self.x 22 | self.pipes['upper'].x = self.x 23 | else 24 | self.remove = true 25 | end 26 | end 27 | 28 | function PipePair:render() 29 | for k, pipe in pairs(self.pipes) do 30 | pipe:render() 31 | end 32 | end -------------------------------------------------------------------------------- /CS50 Games/bird/StateMachine.lua: -------------------------------------------------------------------------------- 1 | StateMachine = Class{} 2 | 3 | function StateMachine:init(states) 4 | self.empty = { 5 | render = function() end, 6 | update = function() end, 7 | enter = function() end, 8 | exit = function() end 9 | } 10 | self.states = states or {} 11 | self.current = self.empty 12 | end 13 | 14 | function StateMachine:change(stateName, enterParams) 15 | assert(self.states[stateName]) 16 | self.current:exit() 17 | self.current = self.states[stateName]() 18 | self.current:enter(enterParams) 19 | end 20 | 21 | function StateMachine:update(dt) 22 | self.current:update(dt) 23 | end 24 | 25 | function StateMachine:render() 26 | self.current:render() 27 | end -------------------------------------------------------------------------------- /CS50 Games/bird/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/background.png -------------------------------------------------------------------------------- /CS50 Games/bird/bird.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/bird.png -------------------------------------------------------------------------------- /CS50 Games/bird/cooper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/cooper.png -------------------------------------------------------------------------------- /CS50 Games/bird/explosion.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/explosion.wav -------------------------------------------------------------------------------- /CS50 Games/bird/flappy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/flappy.ttf -------------------------------------------------------------------------------- /CS50 Games/bird/font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/font.ttf -------------------------------------------------------------------------------- /CS50 Games/bird/gold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/gold.png -------------------------------------------------------------------------------- /CS50 Games/bird/ground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/ground.png -------------------------------------------------------------------------------- /CS50 Games/bird/hurt.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/hurt.wav -------------------------------------------------------------------------------- /CS50 Games/bird/jump.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/jump.wav -------------------------------------------------------------------------------- /CS50 Games/bird/marios_way.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/marios_way.mp3 -------------------------------------------------------------------------------- /CS50 Games/bird/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/pause.png -------------------------------------------------------------------------------- /CS50 Games/bird/pipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/pipe.png -------------------------------------------------------------------------------- /CS50 Games/bird/score.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/score.wav -------------------------------------------------------------------------------- /CS50 Games/bird/silver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Games/bird/silver.png -------------------------------------------------------------------------------- /CS50 Games/bird/states/BaseState.lua: -------------------------------------------------------------------------------- 1 | BaseState = Class{} 2 | 3 | function BaseState:init() end 4 | function BaseState:enter() end 5 | function BaseState:exit() end 6 | function BaseState:update(dt) end 7 | function BaseState:render() end -------------------------------------------------------------------------------- /CS50 Games/bird/states/CountdownState.lua: -------------------------------------------------------------------------------- 1 | CountdownState = Class{__includes = BaseState} 2 | 3 | COUNTDOWN_TIME = 0.75 4 | 5 | function CountdownState:init() 6 | self.count = 3 7 | self.timer = 0 8 | end 9 | 10 | function CountdownState:update(dt) 11 | self.timer = self.timer + dt 12 | 13 | if self.timer > COUNTDOWN_TIME then 14 | self.timer = self.timer % COUNTDOWN_TIME 15 | self.count = self.count - 1 16 | 17 | if self.count == 0 then 18 | gStateMachine:change('play') 19 | end 20 | end 21 | end 22 | 23 | function CountdownState:render() 24 | love.graphics.setFont(hugeFont) 25 | love.graphics.printf(tostring(self.count), 0, 120, VIRTUAL_WIDTH, 'center') 26 | end -------------------------------------------------------------------------------- /CS50 Games/bird/states/TitleScreenState.lua: -------------------------------------------------------------------------------- 1 | TitleScreenState = Class{__includes = BaseState} 2 | 3 | function TitleScreenState:update(dt) 4 | if love.keyboard.wasPressed('enter') or love.keyboard.wasPressed('return') then 5 | gStateMachine:change('countdown') 6 | end 7 | end 8 | 9 | function TitleScreenState:render() 10 | love.graphics.setFont(flappyFont) 11 | love.graphics.printf('Fifty Bird', 0, 64, VIRTUAL_WIDTH, 'center') 12 | 13 | love.graphics.setFont(mediumFont) 14 | love.graphics.printf('Press Enter', 0, 140, VIRTUAL_WIDTH, 'center') 15 | end -------------------------------------------------------------------------------- /CS50 Python/FinalProject/new_students.csv: -------------------------------------------------------------------------------- 1 | name,characteristic,birthdate 2 | Hannah Abbott,patience,2005 3 | Katie Bell,courage,2008 4 | Susan Bones,honesty,2006 5 | Terry Boot,wisdom,2005 6 | Lavender Brown,loyalty,2010 7 | Millicent Bulstrode,competitive,2012 8 | Cho Chang,creativity,2007 9 | Penelope Clearwater,perfectionism,2009 10 | Vincent Crabbe,ambition,2005 11 | Colin Creevey,adventure,2006 12 | -------------------------------------------------------------------------------- /CS50 Python/PSET0/einstein/einstein.py: -------------------------------------------------------------------------------- 1 | # Ask user for mass 2 | m = input("m: ") 3 | 4 | # Convert mass into an integer 5 | # Remember that input() always give you a string 6 | m = int(m) 7 | 8 | # Create variable to store constant 9 | c = 300000000 10 | 11 | # Calculate the formula 12 | E = m * (c ** 2) 13 | 14 | # Print the result 15 | print(E) 16 | -------------------------------------------------------------------------------- /CS50 Python/PSET0/faces/faces.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | # Get user input 3 | msg = input() 4 | # Call convert function 5 | result = convert(msg) 6 | # Print the result 7 | print(result) 8 | 9 | def convert(msg): 10 | # Replace :) for happy emoji 11 | msg = msg.replace(":)", '🙂') 12 | # Replace :( for sad emoji 13 | msg = msg.replace(":(", '🙁') 14 | # Return string 15 | return msg 16 | 17 | main() 18 | -------------------------------------------------------------------------------- /CS50 Python/PSET0/indoor/indoor.py: -------------------------------------------------------------------------------- 1 | # Ask user input 2 | msg = input("What would you like to say? ") 3 | 4 | # Print in lowercase 5 | print(msg.lower()) 6 | -------------------------------------------------------------------------------- /CS50 Python/PSET0/playback/playback.py: -------------------------------------------------------------------------------- 1 | # Get input from the user 2 | msg = input() 3 | 4 | # Change whitespace (" ") for 3 dots ("...") 5 | msg = msg.replace(" ", "...") 6 | 7 | # Print output 8 | print(msg) 9 | -------------------------------------------------------------------------------- /CS50 Python/Pset1/bank/bank.py: -------------------------------------------------------------------------------- 1 | # Get user input 2 | answer = input("Greeting: ") 3 | 4 | # Convert string to lowercase and remove whitespaces 5 | fix_answer = answer.lower().strip() 6 | 7 | # Check if the answer starts with 'hello', print $0 8 | if fix_answer.startswith("hello"): 9 | print("$0") 10 | 11 | # Check if answer starts with 'h', print $20 12 | elif fix_answer.startswith('h'): 13 | print("$20") 14 | 15 | # Otherwise, print $100 16 | else: 17 | print("$100") 18 | -------------------------------------------------------------------------------- /CS50 Python/Pset1/deep/deep.py: -------------------------------------------------------------------------------- 1 | # Get user input 2 | answer = input("What is the answer to the Great Question of Life, the Universe and Everything? ") 3 | 4 | # Convert word to lowercase and remove whitespaces 5 | answer = answer.lower().strip() 6 | 7 | # Print Yes if the user inputs 42 or (case-insensitively) forty-two or forty two 8 | if answer == "42": 9 | print("Yes") 10 | elif answer == "forty-two": 11 | print("Yes") 12 | elif answer == "forty two": 13 | print("Yes") 14 | # Otherwise output No. 15 | else: 16 | print("No") 17 | -------------------------------------------------------------------------------- /CS50 Python/Pset1/extensions/extensions.py: -------------------------------------------------------------------------------- 1 | # Get user input 2 | filename = input("Name of the file: ") 3 | 4 | # Remove spaces and make it all lower 5 | new_filename = filename.lower().strip() 6 | 7 | # Check types 8 | if new_filename.endswith(".gif"): 9 | print("image/gif") 10 | elif new_filename.endswith(".jpg"): 11 | print("image/jpg") 12 | elif new_filename.endswith(".jpeg"): 13 | print("image/jpeg") 14 | elif new_filename.endswith(".png"): 15 | print("image/png") 16 | elif new_filename.endswith(".pdf"): 17 | print("application/pdf") 18 | elif new_filename.endswith(".zip"): 19 | print("application/zip") 20 | elif new_filename.endswith(".txt"): 21 | print("text/plain") 22 | # Otherwise, print "application/octet-stream" 23 | else: 24 | print("application/octet-stream") 25 | -------------------------------------------------------------------------------- /CS50 Python/Pset1/interpreter/interpreter.py: -------------------------------------------------------------------------------- 1 | # Ask user for input 2 | math = input("What do you want to know? ") 3 | 4 | # Get numbers and operators from input 5 | x, y, z = math.split(" ") 6 | 7 | # Convert strings to float 8 | new_x, new_z = float(x), float(z) 9 | 10 | if y == "+": 11 | result = new_x + new_z 12 | elif y == "-": 13 | result = new_x - new_z 14 | elif y == "*": 15 | result = new_x * new_z 16 | elif y == "/" and z != 0: 17 | result = new_x / new_z 18 | else: 19 | print("ZeroDivisionError") 20 | 21 | # Round the result to only one decimal place 22 | print(round(result,1)) 23 | -------------------------------------------------------------------------------- /CS50 Python/Pset2/camel/camel.py: -------------------------------------------------------------------------------- 1 | # Get user input 2 | camelCase = input("camelCase: ") 3 | 4 | # Create empty string 5 | snake_case = "" 6 | 7 | # Loop through every letter 8 | for letter in camelCase: 9 | if letter.isupper(): 10 | snake_case += "_" + letter.lower() 11 | else: 12 | snake_case += letter 13 | 14 | # Print the output 15 | print("snake_case: " + snake_case) 16 | -------------------------------------------------------------------------------- /CS50 Python/Pset2/coke/coke.py: -------------------------------------------------------------------------------- 1 | # Variable to keep track 2 | amount_due = 50 3 | 4 | # Loop forever until we break at some point 5 | while True: 6 | # Print the amount due 7 | print("Amount Due: ", amount_due) 8 | # Ask user to insert coin 9 | coin_inserted = int(input("Insert Coin: ")) 10 | # Check if coin is 25, 10 or 5 cents 11 | if coin_inserted in [25, 10, 5]: 12 | # Subtract value from amount_due 13 | amount_due -= coin_inserted 14 | # Check if amount_due is less or equals to 0 15 | if amount_due <= 0: 16 | # Calculate the change owed 17 | change_owed = abs(amount_due) 18 | # Print the change owed 19 | print("Change Owed: ", change_owed) 20 | break 21 | -------------------------------------------------------------------------------- /CS50 Python/Pset2/twttr/twttr.py: -------------------------------------------------------------------------------- 1 | # Get user input 2 | answer = input("Input: ") 3 | 4 | # Loop through every letter 5 | for letter in answer: 6 | # Check if it is not vowels whether inputted in uppercase or lowercase 7 | if not letter.lower() in ['a', 'e', 'i', 'o', 'u']: 8 | no_vowels += letter 9 | 10 | print("Output: " + no_vowels) 11 | -------------------------------------------------------------------------------- /CS50 Python/Pset3/fuel/fuel.py: -------------------------------------------------------------------------------- 1 | while True: 2 | fuel = input("Fraction: ") 3 | try: 4 | numerator, denominator = fuel.split("/") 5 | new_numerator = int(numerator) 6 | new_denominator = int(denominator) 7 | p = new_numerator / new_denominator 8 | if p <= 1: 9 | break 10 | except (ValueError, ZeroDivisionError): 11 | pass 12 | new_p = int(round(p * 100)) 13 | if new_p <= 1: 14 | print("E") 15 | elif new_p >= 99: 16 | print("F") 17 | else: 18 | print(f"{new_p}%") 19 | -------------------------------------------------------------------------------- /CS50 Python/Pset3/grocery/grocery.py: -------------------------------------------------------------------------------- 1 | grocery = {} 2 | 3 | while True: 4 | try: 5 | item = input() 6 | if item.lower() in grocery: 7 | grocery[item.lower()] += 1 8 | else: 9 | grocery[item.lower()] = 1 10 | except EOFError: 11 | for key in sorted(grocery.keys()): 12 | print(grocery[key], key.upper()) 13 | break 14 | -------------------------------------------------------------------------------- /CS50 Python/Pset4/adieu/adieu.py: -------------------------------------------------------------------------------- 1 | import inflect 2 | 3 | p = inflect.engine() 4 | 5 | # Create list to keep track of names 6 | names_list = [] 7 | # Loop forever 8 | while True: 9 | try: 10 | # Get user input 11 | name = input("Name: ") 12 | names_list.append(name) 13 | except EOFError: 14 | # Create new line and stop the loop 15 | print() 16 | break 17 | # Printing using inflect module 18 | output = p.join(names_list) 19 | print("Adieu, adieu, to "+ output) 20 | -------------------------------------------------------------------------------- /CS50 Python/Pset4/bitcoin/bitcoin.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import sys 3 | 4 | if len(sys.argv) == 2: 5 | try: 6 | value = float(sys.argv[1]) 7 | except: 8 | print("Command-line argument is not a number ") 9 | sys.exit(1) 10 | else: 11 | print("Missing command-line argument") 12 | sys.exit(1) 13 | 14 | try: 15 | r = requests.get('rest.coincap.io/v3/assets/bitcoin?apiKey=YourApiKey') 16 | response = r.json() 17 | bitcoin_to_USD = response['data']['priceUsd'] 18 | amount = float(bitcoin_to_USD) * float(sys.argv[1]) 19 | print(f"${amount:,.4f}") 20 | 21 | except requests.RequestException: 22 | print("RequestException") 23 | sys.exit(1) 24 | -------------------------------------------------------------------------------- /CS50 Python/Pset4/emojize/emojize.py: -------------------------------------------------------------------------------- 1 | import emoji 2 | 3 | user_input = input("Input: ") 4 | 5 | print(emoji.emojize("Output: " + user_input, language="alias")) 6 | -------------------------------------------------------------------------------- /CS50 Python/Pset4/game/game.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | # Get level 4 | while True: 5 | try: 6 | level = int(input("Level: ")) 7 | if level > 0: 8 | break 9 | except: 10 | pass 11 | 12 | # Set random number 13 | random_number = random.randint(1, level) 14 | 15 | # Get guess and check 16 | while True: 17 | try: 18 | guess = int(input("Guess: ")) 19 | if guess > 0: 20 | if guess < random_number: 21 | print("Too small!") 22 | elif guess > random_number: 23 | print("Too large!") 24 | else: 25 | print("Just right!") 26 | break 27 | except: 28 | pass 29 | -------------------------------------------------------------------------------- /CS50 Python/Pset5/test_bank/bank.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | # Get user input 3 | greeting = input("Greeting: ") 4 | # Store the result of value function 5 | value_to_print = value(greeting) 6 | print(f"${value_to_print}") 7 | 8 | 9 | def value(greeting): 10 | # Convert greeting in all lower and without whitespaces 11 | greeting = greeting.lower().strip() 12 | # Check if the answer has 'hello', return 0 13 | if 'hello' in greeting: 14 | return 0 15 | # Check if answer starts with 'h', return 20 16 | elif 'h' == greeting[0]: 17 | return 20 18 | # Otherwise, return 100 19 | else: 20 | return 100 21 | 22 | 23 | if __name__ == "__main__": 24 | main() 25 | -------------------------------------------------------------------------------- /CS50 Python/Pset5/test_bank/test_bank.py: -------------------------------------------------------------------------------- 1 | from bank import value 2 | 3 | def main(): 4 | test_hello_cases() 5 | test_starting_with_h() 6 | test_other_cases() 7 | 8 | def test_hello_cases(): 9 | assert value('hello') == 0 10 | assert value('HELLO') == 0 11 | assert value('hello, Gi') == 0 12 | assert value('Hello, Gi') == 0 13 | 14 | def test_starting_with_h(): 15 | assert value('hi there!') == 20 16 | assert value('How are you?') == 20 17 | 18 | def test_other_cases(): 19 | assert value("What's up?") == 100 20 | assert value("good morning!") == 100 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /CS50 Python/Pset5/test_fuel/test_fuel.py: -------------------------------------------------------------------------------- 1 | from fuel import convert, gauge 2 | import pytest 3 | 4 | 5 | def main(): 6 | test_zero_division() 7 | test_value_error() 8 | test_correct_output() 9 | 10 | 11 | def test_zero_division(): 12 | with pytest.raises(ZeroDivisionError): 13 | convert('1/0') 14 | 15 | 16 | def test_value_error(): 17 | with pytest.raises(ValueError): 18 | convert("cat/dog") 19 | 20 | 21 | def test_correct_output(): 22 | assert convert('1/4') == 25 and gauge(25) == '25%' 23 | assert convert('1/100') == 1 and gauge(1) == 'E' 24 | assert convert('99/100') == 99 and gauge(99) == 'F' 25 | 26 | if __name__ == "__main__": 27 | main() 28 | -------------------------------------------------------------------------------- /CS50 Python/Pset5/test_twttr/test_twttr.py: -------------------------------------------------------------------------------- 1 | from twttr import shorten 2 | 3 | def main(): 4 | test_letter_cases() 5 | test_numbers() 6 | test_punctuation() 7 | 8 | def test_letter_cases(): 9 | assert shorten('apple') == 'ppl' 10 | assert shorten('BANANA') == 'BNN' 11 | assert shorten('OrAnGe') == 'rnG' 12 | 13 | def test_numbers(): 14 | assert shorten('1234') == '1234' 15 | 16 | def test_punctuation(): 17 | assert shorten('!?.,') == '!?.,' 18 | 19 | if __name__ == "__main__": 20 | main() 21 | -------------------------------------------------------------------------------- /CS50 Python/Pset5/test_twttr/twttr.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | # Get user input 3 | message = input("Input: ") 4 | # Remove all vowels 5 | message_without_vowels = shorten(message) 6 | # Print "Output: " 7 | print("Output: " + message_without_vowels) 8 | 9 | 10 | def shorten(word): 11 | word_without_vowels = "" 12 | # Loop through every letter 13 | for letter in word: 14 | # Check if it is not vowels whether inputted in upper case or lowercase 15 | if not letter.lower() in ['a', 'e', 'i', 'o', 'u']: 16 | # Add the letter 17 | word_without_vowels += letter 18 | # Return the new word 19 | return word_without_vowels 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /CS50 Python/Pset7/numb3rs/numb3rs.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def main(): 4 | print(validate(input("IPv4 Address: "))) 5 | 6 | def validate(ip): 7 | if re.search(r"^[0-9_]+\.[0-9_]+\.[0-9_]+\.[0-9_]+$", ip): 8 | split_ip = ip.split(".") 9 | for piece in split_ip: 10 | if int(piece) > 255: 11 | return False 12 | return True 13 | else: 14 | return False 15 | 16 | if __name__ == "__main__": 17 | main() 18 | -------------------------------------------------------------------------------- /CS50 Python/Pset7/numb3rs/test_numb3rs.py: -------------------------------------------------------------------------------- 1 | from numb3rs import validate 2 | 3 | def test_format(): 4 | assert validate(r'cat') == False 5 | assert validate(r'127') == False 6 | assert validate(r'127.0') == False 7 | assert validate(r'127.0.1') == False 8 | assert validate(r'127.0.1.2') == True 9 | 10 | def test_range(): 11 | assert validate(r'255.255.255.255') == True 12 | assert validate(r'512.1.1.1') == False 13 | assert validate(r'1.512.1.1') == False 14 | assert validate(r'1.1.512.1') == False 15 | assert validate(r'1.1.1.512') == False 16 | -------------------------------------------------------------------------------- /CS50 Python/Pset7/response/response.py: -------------------------------------------------------------------------------- 1 | from validator_collection import validators 2 | 3 | def main(): 4 | email_address = input("What's your email address? ") 5 | try: 6 | emailIsValid = validators.email(email_address) 7 | print("Valid") 8 | except: 9 | print("Invalid") 10 | 11 | if __name__ == "__main__": 12 | main() 13 | -------------------------------------------------------------------------------- /CS50 Python/Pset7/um/test_um.py: -------------------------------------------------------------------------------- 1 | from um import count 2 | 3 | def test_upper_lower_case(): 4 | assert count('Um, thanks for the album') == 1 5 | assert count('Um, thanks, UM, for, um, the album') == 3 6 | 7 | 8 | def test_word_with_um(): 9 | assert count('yummi') == 0 10 | 11 | 12 | def test_sourrounded_by_space(): 13 | assert count('Hi um baby') == 1 14 | -------------------------------------------------------------------------------- /CS50 Python/Pset7/um/um.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def main(): 4 | print(count(input("Text: "))) 5 | 6 | 7 | def count(s): 8 | um_list = re.findall(r"\bum\b", s, re.IGNORECASE) 9 | return len(um_list) 10 | 11 | if __name__ == "__main__": 12 | main() 13 | -------------------------------------------------------------------------------- /CS50 Python/Pset7/watch/watch.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def main(): 4 | print(parse(input("HTML: "))) 5 | 6 | 7 | def parse(s): 8 | if re.search(r"<\/iframe>", s): 9 | url_pattern = re.search(r"(http(s)*:\/\/(www\.)*youtube\.com\/embed\/)([a-z_A-Z_0-9]+)", s) 10 | if url_pattern: 11 | split_url = url_pattern.groups() 12 | return "https://youtu.be/" + split_url[3] 13 | 14 | 15 | if __name__ == "__main__": 16 | main() 17 | -------------------------------------------------------------------------------- /CS50 Python/Pset7/working/test_working.py: -------------------------------------------------------------------------------- 1 | from working import convert 2 | import pytest 3 | 4 | # test ValueError 5 | def test_wrong_format(): 6 | with pytest.raises(ValueError): 7 | convert('9 AM - 5 PM') 8 | 9 | 10 | def test_time(): 11 | assert convert('9 AM to 5 PM') == '09:00 to 17:00' 12 | assert convert('10 PM to 8 AM') == '22:00 to 08:00' 13 | assert convert('10:30 PM to 8:50 AM') == '22:30 to 08:50' 14 | 15 | 16 | def test_wrong_hour(): 17 | with pytest.raises(ValueError): 18 | convert('09:00 AM - 17:00') 19 | 20 | 21 | def test_wrong_minute(): 22 | with pytest.raises(ValueError): 23 | convert('9:60 AM to 5:60 PM') 24 | -------------------------------------------------------------------------------- /CS50 Python/Pset8/jar/test_jar.py: -------------------------------------------------------------------------------- 1 | from jar import Jar 2 | 3 | def test_init(): 4 | jar = Jar() 5 | assert jar.capacity == 12 6 | jar2 = Jar(3) 7 | assert jar2.capacity == 3 8 | 9 | def test_str(): 10 | jar = Jar() 11 | assert str(jar) == "" 12 | jar.deposit(1) 13 | assert str(jar) == "🍪" 14 | jar.deposit(11) 15 | assert str(jar) == "🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪" 16 | 17 | def test_deposit(): 18 | jar = Jar() 19 | jar.deposit(3) 20 | assert jar.size == 3 21 | 22 | def test_withdraw(): 23 | jar = Jar() 24 | jar.deposit(3) 25 | jar.withdraw(2) 26 | assert jar.size == 1 27 | -------------------------------------------------------------------------------- /CS50 Python/Pset8/seasons/seasons.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | import sys 3 | import re 4 | import inflect 5 | 6 | p = inflect.engine() 7 | 8 | def main(): 9 | birthday = input("Date of Birth: ") 10 | try: 11 | year, month, day = check_birthday(birthday) 12 | except: 13 | sys.exit("Invalid date") 14 | birthDate = date(int(year), int(month), int(day)) 15 | todayDate = date.today() 16 | diff = todayDate - birthDate 17 | total_minutes = diff.days * 24 * 60 18 | output = p.number_to_words(total_minutes, andword='') 19 | print(output.capitalize() + " minutes") 20 | 21 | 22 | def check_birthday(birthday): 23 | if re.search(r"^[0-9]{4}-[0-9]{2}-[0-9]{2}$", birthday): 24 | year, month, day = birthday.split("-") 25 | return year, month, day 26 | 27 | 28 | if __name__ == "__main__": 29 | main() 30 | -------------------------------------------------------------------------------- /CS50 Python/Pset8/seasons/test_seasons.py: -------------------------------------------------------------------------------- 1 | from seasons import check_birthday 2 | 3 | def test_check_birthday(): 4 | assert check_birthday("July 3, 1998") == None 5 | assert check_birthday("1998-7-3") == None 6 | assert check_birthday("1998-07-03") == ("1998", "07", "03") 7 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/1.sql: -------------------------------------------------------------------------------- 1 | SELECT "title" FROM "episodes" 2 | WHERE season = 1; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/10.sql: -------------------------------------------------------------------------------- 1 | SELECT id, title, production_code FROM episodes 2 | ORDER BY production_code ASC; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/11.sql: -------------------------------------------------------------------------------- 1 | SELECT title FROM episodes 2 | WHERE season = 5 3 | ORDER BY title DESC; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/12.sql: -------------------------------------------------------------------------------- 1 | SELECT count(DISTINCT title) FROM episodes; 2 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/13.sql: -------------------------------------------------------------------------------- 1 | SELECT title FROM episodes 2 | WHERE topic LIKE "%fraction%" AND air_date < '2020-01-01'; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/2.sql: -------------------------------------------------------------------------------- 1 | -- List the season number of, and title of, the first episode of every season. 2 | SELECT season, title FROM episodes 3 | WHERE episode_in_season = 1; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/3.sql: -------------------------------------------------------------------------------- 1 | SELECT "production_code" FROM "episodes" 2 | WHERE title = "Hackerized!"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/4.sql: -------------------------------------------------------------------------------- 1 | -- Write a query to find the titles of episodes that do not yet have a listed topic. 2 | SELECT title FROM episodes 3 | WHERE topic IS NULL; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/5.sql: -------------------------------------------------------------------------------- 1 | SELECT title FROM episodes 2 | WHERE air_date = "2004-12-31"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/6.sql: -------------------------------------------------------------------------------- 1 | SELECT title FROM episodes 2 | WHERE season = 6 AND air_date < "2008-01-01"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/7.sql: -------------------------------------------------------------------------------- 1 | SELECT title, topic FROM episodes 2 | WHERE topic LIKE "%fraction%"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/8.sql: -------------------------------------------------------------------------------- 1 | SELECT count(title) FROM episodes 2 | WHERE air_date BETWEEN '2018-01-01' AND '2023-12-31'; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/cyberchase/9.sql: -------------------------------------------------------------------------------- 1 | SELECT count(title) FROM episodes 2 | WHERE air_date BETWEEN '2002-01-01' AND '2007-12-31'; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/1.sql: -------------------------------------------------------------------------------- 1 | SELECT "0m" FROM "normals" 2 | WHERE "latitude" = 42.5 AND "longitude" = -69.5; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/10.sql: -------------------------------------------------------------------------------- 1 | SELECT COUNT(DISTINCT latitude) AS "Number of Latitudes With Data" 2 | FROM normals; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/2.sql: -------------------------------------------------------------------------------- 1 | SELECT "225m" FROM "normals" 2 | WHERE "latitude" = 42.5 AND "longitude" = -69.5; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/3.sql: -------------------------------------------------------------------------------- 1 | SELECT "225m" FROM "normals" 2 | WHERE "latitude" = -77.5 AND "longitude" = -178.5; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/4.sql: -------------------------------------------------------------------------------- 1 | SELECT MIN("0m") FROM normals; 2 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/5.sql: -------------------------------------------------------------------------------- 1 | SELECT MAX("0m") FROM normals; 2 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/6.sql: -------------------------------------------------------------------------------- 1 | SELECT latitude, longitude, "50m" AS temperature 2 | FROM normals 3 | WHERE latitude BETWEEN 0 AND 20 4 | AND longitude BETWEEN 55 AND 75; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/7.sql: -------------------------------------------------------------------------------- 1 | SELECT ROUND(AVG("0m"), 2) AS "Average Equator Ocean Surface Temperature" 2 | FROM normals 3 | WHERE latitude BETWEEN -0.5 AND 0.5; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/8.sql: -------------------------------------------------------------------------------- 1 | SELECT latitude, longitude, "0m" AS "surface temperature" 2 | FROM normals 3 | ORDER BY "0m", latitude 4 | LIMIT 10; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/normals/9.sql: -------------------------------------------------------------------------------- 1 | SELECT latitude, longitude, "0m" AS "surface temperature" 2 | FROM normals 3 | ORDER BY "0m" DESC, latitude 4 | LIMIT 10; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/1.sql: -------------------------------------------------------------------------------- 1 | SELECT birth_city, birth_state, birth_country FROM players 2 | WHERE first_name = "Jackie" AND last_name = "Robinson"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/10.sql: -------------------------------------------------------------------------------- 1 | SELECT first_name, last_name, debut FROM players 2 | WHERE final_game LIKE "2022-%" 3 | ORDER BY debut; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/2.sql: -------------------------------------------------------------------------------- 1 | SELECT bats FROM players 2 | WHERE first_name = "Babe" AND last_name = "Ruth"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/3.sql: -------------------------------------------------------------------------------- 1 | SELECT id FROM players 2 | WHERE debut IS NULL; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/4.sql: -------------------------------------------------------------------------------- 1 | SELECT first_name, last_name FROM players 2 | WHERE birth_country != "USA" 3 | ORDER BY first_name, last_name ASC; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/5.sql: -------------------------------------------------------------------------------- 1 | SELECT first_name, last_name FROM players 2 | WHERE bats = "R" 3 | ORDER BY first_name ASC, last_name ASC; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/6.sql: -------------------------------------------------------------------------------- 1 | SELECT first_name, last_name, debut FROM players 2 | WHERE birth_city = "Pittsburgh" AND birth_state = "PA" 3 | ORDER BY debut DESC, first_name ASC, last_name ASC; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/7.sql: -------------------------------------------------------------------------------- 1 | SELECT COUNT(id) FROM players 2 | WHERE (bats = "R" AND throws = "L") OR (bats = "L" AND throws = "R"); 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/8.sql: -------------------------------------------------------------------------------- 1 | SELECT ROUND(AVG(height),2) AS "Average Height", ROUND(AVG(weight),2) AS "Average Weight" FROM players 2 | WHERE debut >= "2000-01-01"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/players/9.sql: -------------------------------------------------------------------------------- 1 | SELECT first_name, last_name FROM players 2 | WHERE final_game LIKE "2022-%" 3 | ORDER BY first_name, last_name; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/1.sql: -------------------------------------------------------------------------------- 1 | SELECT japanese_title, english_title 2 | FROM views; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/10.sql: -------------------------------------------------------------------------------- 1 | SELECT english_title, artist FROM views 2 | WHERE english_title LIKE "%Fuji%" 3 | ORDER BY brightness DESC 4 | LIMIT 1; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/2.sql: -------------------------------------------------------------------------------- 1 | SELECT average_color FROM views 2 | WHERE artist = "Hokusai" AND english_title LIKE "%river%"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/3.sql: -------------------------------------------------------------------------------- 1 | SELECT COUNT(english_title) FROM views 2 | WHERE artist = "Hokusai" AND english_title LIKE "%Fuji%"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/4.sql: -------------------------------------------------------------------------------- 1 | SELECT COUNT(english_title) FROM views 2 | WHERE artist = "Hiroshige" AND english_title LIKE "%Eastern Capital%"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/5.sql: -------------------------------------------------------------------------------- 1 | SELECT MAX(contrast) as 'Maximum Contrast' FROM views; 2 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/6.sql: -------------------------------------------------------------------------------- 1 | SELECT ROUND(AVG(entropy),2) AS 'Hiroshige Average Entropy' FROM views 2 | WHERE artist = "Hiroshige"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/7.sql: -------------------------------------------------------------------------------- 1 | SELECT english_title FROM views 2 | WHERE artist = "Hiroshige" 3 | ORDER BY brightness DESC 4 | LIMIT 5; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/8.sql: -------------------------------------------------------------------------------- 1 | SELECT english_title FROM views 2 | WHERE artist = "Hokusai" 3 | ORDER BY contrast asc 4 | LIMIT 5; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week 0/views/9.sql: -------------------------------------------------------------------------------- 1 | SELECT english_title, artist FROM views 2 | ORDER BY brightness DESC 3 | LIMIT 1; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/1.sql: -------------------------------------------------------------------------------- 1 | SELECT name, city FROM schools 2 | WHERE state = 'MA' and type = 'Public School'; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/10.sql: -------------------------------------------------------------------------------- 1 | SELECT districts.name, expenditures.per_pupil_expenditure FROM expenditures 2 | JOIN districts ON districts.id = expenditures.district_id 3 | WHERE type LIKE '%Public School%' 4 | ORDER BY expenditures.per_pupil_expenditure DESC 5 | LIMIT 10; 6 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/11.sql: -------------------------------------------------------------------------------- 1 | SELECT schools.name, expenditures.per_pupil_expenditure, graduation_rates.graduated FROM expenditures 2 | JOIN districts ON districts.id = expenditures.district_id 3 | JOIN schools ON schools.district_id = districts.id 4 | JOIN graduation_rates ON schools.id = graduation_rates.school_id 5 | ORDER BY expenditures.per_pupil_expenditure DESC, schools.name ASC; 6 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/12.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | districts.name, 3 | expenditures.per_pupil_expenditure, 4 | staff_evaluations.exemplary 5 | FROM expenditures 6 | JOIN districts ON districts.id = expenditures.district_id 7 | JOIN staff_evaluations ON districts.id = staff_evaluations.district_id 8 | WHERE 9 | districts.type LIKE 'Public School%' 10 | AND expenditures.per_pupil_expenditure > ( 11 | SELECT AVG(per_pupil_expenditure) 12 | FROM expenditures 13 | ) 14 | AND staff_evaluations.exemplary > ( 15 | SELECT AVG(exemplary) 16 | FROM staff_evaluations 17 | ) 18 | ORDER BY 19 | staff_evaluations.exemplary DESC, 20 | expenditures.per_pupil_expenditure DESC; 21 | 22 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/13.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT districts.city, AVG(per_pupil_expenditure) as 'Average Per Pupil Expenditure' FROM expenditures 2 | JOIN districts ON districts.id = expenditures.district_id 3 | GROUP BY districts.city 4 | ORDER BY AVG(per_pupil_expenditure) DESC; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/2.sql: -------------------------------------------------------------------------------- 1 | SELECT name FROM districts 2 | WHERE name LIKE "%(non-op)"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/3.sql: -------------------------------------------------------------------------------- 1 | SELECT AVG(per_pupil_expenditure) AS 'Average District Per-Pupil Expenditure' FROM expenditures; 2 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/4.sql: -------------------------------------------------------------------------------- 1 | SELECT city, COUNT(name) AS public_school_count 2 | FROM schools 3 | WHERE type = 'Public School' 4 | GROUP BY city 5 | ORDER BY public_school_count DESC, city ASC 6 | LIMIT 10; 7 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/5.sql: -------------------------------------------------------------------------------- 1 | SELECT city, COUNT(name) AS public_school_count 2 | FROM schools 3 | WHERE type = 'Public School' 4 | GROUP BY city 5 | HAVING public_school_count <= 3 6 | ORDER BY public_school_count DESC, city ASC; 7 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/6.sql: -------------------------------------------------------------------------------- 1 | SELECT name FROM schools 2 | WHERE id in ( 3 | SELECT school_id FROM graduation_rates 4 | WHERE graduated = 100 5 | ); 6 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/7.sql: -------------------------------------------------------------------------------- 1 | SELECT name FROM schools 2 | WHERE district_id IN ( 3 | SELECT id FROM districts 4 | WHERE name = "Cambridge" 5 | ); 6 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/8.sql: -------------------------------------------------------------------------------- 1 | SELECT districts.name, expenditures.pupils FROM expenditures 2 | JOIN districts ON districts.id = expenditures.district_id; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week1/dese/9.sql: -------------------------------------------------------------------------------- 1 | SELECT districts.name FROM expenditures 2 | JOIN districts ON districts.id = expenditures.district_id 3 | ORDER BY expenditures.pupils 4 | LIMIT 1; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/1.sql: -------------------------------------------------------------------------------- 1 | SELECT year, ROUND(AVG(salary),2) AS 'average salary' FROM salaries 2 | GROUP BY year 3 | ORDER BY year DESC; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/10.sql: -------------------------------------------------------------------------------- 1 | SELECT players.first_name, players.last_name, salaries.salary, performances.HR, salaries.year 2 | FROM players 3 | JOIN salaries ON salaries.player_id = players.id 4 | JOIN performances ON performances.player_id = players.id AND performances.year = salaries.year 5 | ORDER BY 6 | players.id ASC, 7 | salaries.year DESC, 8 | performances.HR DESC, 9 | salaries.salary DESC; 10 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/11.sql: -------------------------------------------------------------------------------- 1 | SELECT players.first_name, players.last_name, salaries.salary/performances.H AS 'dollars per hit' 2 | FROM players 3 | JOIN salaries ON salaries.player_id = players.id 4 | JOIN performances ON performances.player_id = players.id AND performances.year = salaries.year 5 | WHERE salaries.year = 2001 AND performances.H > 0 6 | ORDER BY 7 | salaries.salary/performances.H ASC, 8 | players.first_name ASC, 9 | players.last_name ASC 10 | LIMIT 10; 11 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/2.sql: -------------------------------------------------------------------------------- 1 | SELECT year, salary FROM salaries 2 | WHERE player_id = ( 3 | SELECT id FROM players 4 | WHERE first_name = 'Cal' AND last_name LIKE 'Ripken%' 5 | ) 6 | ORDER BY year DESC; 7 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/3.sql: -------------------------------------------------------------------------------- 1 | SELECT year, HR FROM performances 2 | WHERE player_id = ( 3 | SELECT id FROM players 4 | WHERE first_name = 'Ken' AND last_name LIKE 'Griffey%' AND birth_year = 1969 5 | ) 6 | ORDER BY year DESC; 7 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/4.sql: -------------------------------------------------------------------------------- 1 | SELECT first_name, last_name, salary FROM players 2 | JOIN salaries ON salaries.player_id = players.id 3 | WHERE year = 2001 4 | ORDER BY salary ASC, first_name ASC, last_name ASC, players.id ASC 5 | LIMIT 50; 6 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/5.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT teams.name FROM teams 2 | JOIN performances ON performances.team_id = teams.id 3 | JOIN players ON players.id = performances.player_id 4 | WHERE players.first_name = 'Satchel' AND players.last_name = 'Paige'; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/6.sql: -------------------------------------------------------------------------------- 1 | SELECT teams.name, SUM(performances.H) AS 'total hits' FROM teams 2 | JOIN performances ON performances.team_id = teams.id 3 | WHERE performances.year = 2001 4 | GROUP BY teams.name 5 | ORDER BY SUM(performances.H) DESC 6 | LIMIT 5; 7 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/7.sql: -------------------------------------------------------------------------------- 1 | SELECT players.first_name, players.last_name FROM players 2 | JOIN salaries ON salaries.player_id = players.id 3 | WHERE salaries.salary = ( 4 | SELECT MAX(salary) FROM salaries 5 | ); 6 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/8.sql: -------------------------------------------------------------------------------- 1 | SELECT salary FROM salaries 2 | WHERE player_id = ( 3 | SELECT player_id FROM performances 4 | WHERE year = 2001 5 | ORDER BY HR DESC 6 | LIMIT 1 7 | ) AND year = 2001; 8 | -------------------------------------------------------------------------------- /CS50 SQL/week1/moneyball/9.sql: -------------------------------------------------------------------------------- 1 | SELECT teams.name, ROUND(AVG(salaries.salary),2) FROM salaries 2 | JOIN teams ON teams.id = salaries.team_id 3 | WHERE salaries.year = 2001 4 | GROUP BY teams.name 5 | ORDER BY ROUND(AVG(salaries.salary),2) ASC 6 | LIMIT 5; 7 | -------------------------------------------------------------------------------- /CS50 SQL/week1/packages/answers.txt: -------------------------------------------------------------------------------- 1 | 2 | At what type of address did the Lost Letter end up?: Residential 3 | At what address did the Lost Letter end up?: 2 Finnigan Street 4 | 5 | At what type of address did the Devious Delivery end up?: Police Station 6 | What were the contents of the Devious Delivery?: Duck debugger 7 | 8 | What are the contents of the Forgotten Gift?: Flowers 9 | Who has the Forgotten Gift?: Mikel 10 | -------------------------------------------------------------------------------- /CS50 SQL/week3/dont-panic/hack.sql: -------------------------------------------------------------------------------- 1 | -- 1. Alter the password of the 'admin' account 2 | -- The MD5 hash for "oops!" is 982c0381c279d139fd221fce974916e7 (You can find this from md5hashgenerator.com). 3 | UPDATE "users" 4 | SET "password" = '982c0381c279d139fd221fce974916e7' 5 | WHERE "username" = 'admin'; 6 | 7 | -- 2. Erase any logs of your activity 8 | DELETE FROM "user_logs"; 9 | 10 | -- 3. Add false data 11 | -- First, get the password for 'emily33' 12 | INSERT INTO "user_logs" ("type", "old_username", "new_username", "old_password", "new_password") 13 | SELECT 'update', 'admin', 'admin', "password", "password" 14 | FROM "users" 15 | WHERE "username" = 'emily33'; 16 | -------------------------------------------------------------------------------- /CS50 SQL/week4/bnb/available.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "available" AS 2 | SELECT listings.id, listings.property_type, listings.host_name, availabilities.date FROM listings 3 | JOIN availabilities ON listings.id = availabilities.listing_id 4 | WHERE available = "TRUE"; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week4/bnb/frequently_reviewed.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "frequently_reviewed" AS 2 | SELECT listings.id, listings.property_type, listings.host_name FROM listings 3 | JOIN reviews ON listings.id = reviews.listing_id 4 | GROUP BY reviews.listing_id 5 | ORDER BY COUNT(reviews.listing_id) DESC, property_type, host_name 6 | LIMIT 100; 7 | -------------------------------------------------------------------------------- /CS50 SQL/week4/bnb/june_vacancies.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "june_vacancies" AS 2 | SELECT listings.id, listings.property_type, listings.host_name, COUNT(availabilities.date) AS "days_vacant" FROM listings 3 | JOIN availabilities ON listings.id = availabilities.listing_id 4 | WHERE availabilities.date LIKE "2023-06-%" AND availabilities.available = "TRUE" 5 | GROUP BY listings.id; 6 | -------------------------------------------------------------------------------- /CS50 SQL/week4/bnb/no_descriptions.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "no_descriptions" AS 2 | SELECT id, property_type, host_name, accommodates, bedrooms FROM listings; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week4/bnb/one_bedrooms.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "one_bedrooms" AS 2 | SELECT id, property_type, host_name, accommodates FROM listings 3 | WHERE bedrooms = 1; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week4/census/by_district.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "by_district" AS 2 | SELECT district, SUM(families) as "families", sum(households), SUM(population), SUM(male), SUM(female) FROM "census" 3 | GROUP BY district; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week4/census/most_populated.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "most_populated" AS 2 | SELECT district, SUM(families), sum(households), SUM(population), SUM(male), SUM(female) FROM "census" 3 | GROUP BY district 4 | ORDER BY SUM(population) DESC; 5 | -------------------------------------------------------------------------------- /CS50 SQL/week4/census/rural.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "rural" AS 2 | SELECT * FROM "census" 3 | WHERE locality LIKE "%rural%"; 4 | -------------------------------------------------------------------------------- /CS50 SQL/week4/census/total.sql: -------------------------------------------------------------------------------- 1 | CREATE VIEW "total" AS 2 | SELECT SUM(families), sum(households) AS "households", SUM(population), SUM(male), SUM(female) FROM "census"; 3 | -------------------------------------------------------------------------------- /CS50 SQL/week4/private/private.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "triplets" ( 2 | "sentence_id" INTEGER, 3 | "start_char" INTEGER, 4 | "length" INTEGER 5 | ); 6 | 7 | INSERT INTO "triplets" ("sentence_id", "start_char", "length") VALUES 8 | (14, 98, 4), 9 | (114, 3, 5), 10 | (618, 72, 9), 11 | (630, 7, 3), 12 | (932, 12, 5), 13 | (2230, 50, 7), 14 | (2346, 44, 10), 15 | (3041, 14, 5); 16 | 17 | CREATE VIEW "message" AS 18 | SELECT substr(s."sentence", t."start_char", t."length") AS "phrase" 19 | FROM "sentences" s 20 | JOIN "triplets" t ON s."id" = t."sentence_id"; 21 | 22 | SELECT "phrase" FROM "message"; 23 | -------------------------------------------------------------------------------- /CS50 SQL/week5/harvard/harvard.sql: -------------------------------------------------------------------------------- 1 | -- Students table 2 | -- Assuming id is already indexed as a primary key 3 | 4 | -- Courses table 5 | CREATE INDEX idx_courses_department ON courses(department); 6 | CREATE INDEX idx_courses_dept_num_sem ON courses(department, number, semester); 7 | CREATE INDEX idx_courses_title ON courses(title); 8 | 9 | -- Enrollments table 10 | CREATE INDEX idx_enrollments_student_course ON enrollments(student_id, course_id); 11 | CREATE INDEX idx_enrollments_course ON enrollments(course_id); 12 | 13 | -- Requirements table 14 | -- Assuming id is already indexed as a primary key 15 | 16 | -- Satisfies table 17 | CREATE INDEX idx_satisfies_course ON satisfies(course_id); 18 | CREATE INDEX idx_satisfies_requirement ON satisfies(requirement_id); 19 | -------------------------------------------------------------------------------- /CS50 SQL/week6/dont-panic-python/hack.py: -------------------------------------------------------------------------------- 1 | from cs50 import SQL 2 | 3 | 4 | db = SQL("sqlite:///dont-panic.db") 5 | password = input("Enter a password: ") 6 | db.execute( 7 | """ 8 | UPDATE "users" 9 | SET "password" = ? 10 | WHERE "username" = 'admin'; 11 | """, 12 | password 13 | ) 14 | -------------------------------------------------------------------------------- /CS50 Web/commerce/auctions/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.contrib.auth.admin import UserAdmin 3 | from .models import User, Listing, Bid 4 | # Register your models here. 5 | 6 | admin.site.register(User, UserAdmin) 7 | admin.site.register(Listing) 8 | admin.site.register(Bid) -------------------------------------------------------------------------------- /CS50 Web/commerce/auctions/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AuctionsConfig(AppConfig): 5 | name = 'auctions' 6 | -------------------------------------------------------------------------------- /CS50 Web/commerce/auctions/templates/auctions/login.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 | 5 |

Login

6 | 7 |
8 | {% csrf_token %} 9 |
10 | 11 |
12 |
13 | 14 |
15 | 16 |
17 | 18 | Don't have an account? Register here. 19 | 20 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/commerce/auctions/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /CS50 Web/commerce/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'commerce.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /CS50 Web/mail/README.md: -------------------------------------------------------------------------------- 1 | CS50 Web 2 | Project 3 - Mail 3 | -------------------------------------------------------------------------------- /CS50 Web/mail/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Web/mail/__init__.py -------------------------------------------------------------------------------- /CS50 Web/mail/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /CS50 Web/mail/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class MailConfig(AppConfig): 5 | name = 'mail' 6 | -------------------------------------------------------------------------------- /CS50 Web/mail/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /CS50 Web/mail/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path("", views.index, name="index"), 7 | path("login", views.login_view, name="login"), 8 | path("logout", views.logout_view, name="logout"), 9 | path("register", views.register, name="register"), 10 | 11 | # API Routes 12 | path("emails", views.compose, name="compose"), 13 | path("emails/", views.email, name="email"), 14 | path("emails/", views.mailbox, name="mailbox"), 15 | ] 16 | -------------------------------------------------------------------------------- /CS50 Web/network/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Post, User, Follow, Like 3 | 4 | # Register your models here. 5 | admin.site.register(Post) 6 | admin.site.register(User) 7 | admin.site.register(Follow) 8 | admin.site.register(Like) -------------------------------------------------------------------------------- /CS50 Web/network/templates/network/login.html: -------------------------------------------------------------------------------- 1 | {% extends "network/layout.html" %} 2 | 3 | {% block body %} 4 | 5 |

Login

6 | 7 | {% if message %} 8 |
{{ message }}
9 | {% endif %} 10 | 11 |
12 | {% csrf_token %} 13 |
14 | 15 |
16 |
17 | 18 |
19 | 20 |
21 | 22 | Don't have an account? Register here. 23 | 24 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/network/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path 3 | 4 | from . import views 5 | 6 | urlpatterns = [ 7 | path("", views.index, name="index"), 8 | path("login", views.login_view, name="login"), 9 | path("logout", views.logout_view, name="logout"), 10 | path("register", views.register, name="register"), 11 | path("newPost", views.newPost, name="newPost"), 12 | path("profile/", views.profile, name="profile"), 13 | path("unfollow", views.unfollow, name="unfollow"), 14 | path("follow", views.follow, name="follow"), 15 | path("following", views.following, name="following"), 16 | path("edit/", views.edit, name="edit"), 17 | path("remove_like/", views.remove_like, name="remove_like"), 18 | path("add_like/", views.add_like, name="add_like"), 19 | ] 20 | -------------------------------------------------------------------------------- /CS50 Web/search/advanced.css: -------------------------------------------------------------------------------- 1 | #icon { 2 | height: 40px; 3 | width: 120px; 4 | } 5 | 6 | #search-title { 7 | margin-top: 20px; 8 | margin-left: 40px; 9 | font-size: 15px; 10 | color: red; 11 | } 12 | #advanced-search { 13 | margin-left: 45px; 14 | margin-top: 30px; 15 | } 16 | 17 | #submit { 18 | margin-top: 20px; 19 | margin-left: 500px; 20 | } 21 | .text-field { 22 | margin-left: 40px; 23 | width: 800px; 24 | } 25 | 26 | #link-back{ 27 | margin-left: 900px; 28 | } -------------------------------------------------------------------------------- /CS50 Web/search/google.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Web/search/google.png -------------------------------------------------------------------------------- /CS50 Web/search/googleimg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/CS50 Web/search/googleimg.png -------------------------------------------------------------------------------- /CS50 Web/search/styles.css: -------------------------------------------------------------------------------- 1 | #search { 2 | margin-top: 40px; 3 | } 4 | 5 | #google-icon { 6 | height: 90px; 7 | margin-top: 140px; 8 | } 9 | 10 | .buttons { 11 | margin-top: 15px; 12 | margin-left: 110px; 13 | } 14 | .btn { 15 | background-color: #F6F6F6; 16 | } 17 | .input-icons i { 18 | position: absolute; 19 | } 20 | 21 | .input-icons { 22 | width: 100%; 23 | margin-bottom: 10px; 24 | } 25 | 26 | .icon { 27 | padding: 10px; 28 | min-width: 40px; 29 | } 30 | 31 | .input-field { 32 | width: 100%; 33 | padding: 10px; 34 | text-indent: 30px; 35 | } 36 | 37 | #input { 38 | width: 500px; 39 | border-radius: 30px; 40 | } -------------------------------------------------------------------------------- /CS50 Web/search/styles_image.css: -------------------------------------------------------------------------------- 1 | #search { 2 | margin-top: 20px; 3 | } 4 | 5 | #google-icon { 6 | height: 150px; 7 | margin-top: 100px; 8 | } 9 | 10 | .buttons { 11 | margin-top: 15px; 12 | margin-left: 180px; 13 | } 14 | .btn { 15 | background-color: #F6F6F6; 16 | } 17 | .input-icons i { 18 | position: absolute; 19 | } 20 | 21 | .input-icons { 22 | width: 100%; 23 | margin-bottom: 10px; 24 | } 25 | 26 | .icon { 27 | padding: 10px; 28 | min-width: 40px; 29 | } 30 | 31 | .input-field { 32 | width: 100%; 33 | padding: 10px; 34 | text-indent: 30px; 35 | } 36 | 37 | #input { 38 | width: 500px; 39 | border-radius: 30px; 40 | } -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class EncyclopediaConfig(AppConfig): 5 | name = 'encyclopedia' 6 | -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/templates/already_exist.html: -------------------------------------------------------------------------------- 1 | {% extends "encyclopedia/layout.html" %} 2 | 3 | 4 | {% block body %} 5 |

This entry already exists!!!!

6 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/templates/edit.html: -------------------------------------------------------------------------------- 1 | {% extends "encyclopedia/layout.html" %} 2 | 3 | {% block title %} 4 | {% endblock %} 5 | 6 | {% block body %} 7 |
8 | {% csrf_token %} 9 |
10 | 11 | 12 |
13 |
14 | 15 | 16 |
17 | 18 |
19 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/templates/entry.html: -------------------------------------------------------------------------------- 1 | {% extends "encyclopedia/layout.html" %} 2 | 3 | {% block title %} 4 | {{entryTitle}} 5 | {% endblock %} 6 | 7 | {% block body %} 8 | {{ entry | safe }} 9 |
10 | {% csrf_token %} 11 | 12 | 13 |
14 | 15 | 16 | 17 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "encyclopedia/layout.html" %} 2 | 3 | {% block title %} 4 | Encyclopedia 5 | {% endblock %} 6 | 7 | {% block body %} 8 |

All Pages

9 | 10 |
    11 | {% for entry in entries %} 12 |
  • {{entry}}
  • 13 | {% endfor %} 14 |
15 | 16 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/templates/new.html: -------------------------------------------------------------------------------- 1 | {% extends "encyclopedia/layout.html" %} 2 | 3 | {% block title %} 4 | {% endblock %} 5 | 6 | {% block body %} 7 |
8 | {% csrf_token %} 9 |
10 | 11 | 12 |
13 |
14 | 15 | 16 |
17 | 18 |
19 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/templates/search.html: -------------------------------------------------------------------------------- 1 | {% extends "encyclopedia/layout.html" %} 2 | 3 | {% block title %} 4 | Search 5 | {% endblock %} 6 | 7 | {% block body %} 8 |

Pages similar to your search

9 | 10 |
    11 | {% for entry in entries %} 12 |
  • {{entry}}
  • 13 | {% endfor %} 14 |
15 | 16 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/templates/wrong_entry.html: -------------------------------------------------------------------------------- 1 | {% extends "encyclopedia/layout.html" %} 2 | 3 | {% block title %} 4 | {{entryTitle}} 5 | {% endblock %} 6 | 7 | {% block body %} 8 |

{{entryTitle}} does not exist

9 |

Check out another page!

10 | {% endblock %} -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /CS50 Web/wiki/encyclopedia/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | 6 | urlpatterns = [ 7 | path("", views.index, name="index"), 8 | path("wiki/", views.entry, name="entry"), 9 | path("search", views.search, name="search"), 10 | path("new", views.new, name="new"), 11 | path("save", views.save, name="save"), 12 | path("random", views.rand, name="random"), 13 | path("edit", views.edit, name="edit"), 14 | path("save_edit", views.save_edit, name="save_edit"), 15 | ] 16 | -------------------------------------------------------------------------------- /CS50 Web/wiki/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wiki.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/10_convert_miles.py: -------------------------------------------------------------------------------- 1 | # Title: convert_miles 2 | 3 | """ 4 | Given an integer 'n', return the kilometers that this number of miles represents. Hint: 1 mile = 1.60934 kilometers. 5 | 6 | convert_miles(1) -> 1.60934 7 | 8 | convert_miles(0.4) -> 0.643736 9 | """ 10 | 11 | def convert_miles(n: float)->float: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(convert_miles(1)) # Output: 1.6093 16 | print(convert_miles(0.4)) # Output: 0.6437 17 | print(convert_miles(10)) # Output: 16.0934 18 | print(convert_miles(-5)) # Output: -8.0467 19 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/1_return_hello.py: -------------------------------------------------------------------------------- 1 | # Title: return_hello 2 | 3 | """ 4 | Given a string 's', return a new string with the word "hello" in front. 5 | 6 | return_hello("Gi") -> "hello Gi" 7 | 8 | return_hello("Leo") -> "hello Leo" 9 | """ 10 | 11 | def return_hello(s: str)-> str: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(return_hello('Gi')) # Output: 'hello Gi' 16 | print(return_hello('Leo')) # Output: 'hello Leo' 17 | print(return_hello('world')) # Output: 'hello world' 18 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/241_calc_bmi.py: -------------------------------------------------------------------------------- 1 | # Title: calc_bmi 2 | 3 | """ 4 | Given an integer 'weight' and an integer 'height', return the Body Mass Index (BMI) of the person. The BMI will be in a format of a float. 5 | 6 | Hint: the formula to calculate BMI is weight / (height/100)^2. 7 | 8 | calc_bmi(75, 180) -> 23.15 9 | calc_bmi(90, 190) -> 24.93 10 | calc_bmi(80, 170) -> 27.68 11 | """ 12 | 13 | def calc_bmi(weight: int, height: int)->float: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(calc_bmi(75, 180)) # Output: 23.15 18 | print(calc_bmi(90, 190)) # Output: 24.93 19 | print(calc_bmi(80, 170)) # Output: 27.68 20 | print(calc_bmi(60, 165)) # Output: 22.04 21 | print(calc_bmi(70, 160)) # Output: 27.34 22 | print(calc_bmi(65, 175)) # Output: 21.22 23 | print(calc_bmi(100, 200)) # Output: 25.0 24 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/242_volume_of_cylinder.py: -------------------------------------------------------------------------------- 1 | # Title: volume_of_cylinder 2 | 3 | """ 4 | Given an integer 'height' and an integer 'diameter', return the volume of a cylinder given its height and diameter. The volume will be in a format of a float. 5 | 6 | Hint: the formula to calculate the volume of a cylinder is 3.14 * (diameter/2)^2 * height. 7 | 8 | volume_of_cylinder(10, 4) -> 125.6 9 | volume_of_cylinder(5, 2) -> 15.70 10 | volume_of_cylinder(7, 4) -> 87.92 11 | """ 12 | 13 | def volume_of_cylinder(height: int, diameter: int)->float: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | # No test for this exercise. 18 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/243_convert_seconds.py: -------------------------------------------------------------------------------- 1 | # Title: convert_seconds 2 | 3 | """ 4 | Given an integer 'n' that represents the minutes, return how many seconds that amount of minutes represent. 5 | 6 | Hint: 1 minute = 60 seconds 7 | 8 | convert_seconds(24) -> 1440 9 | convert_seconds(59) -> 3540 10 | convert_seconds(9) -> 540 11 | """ 12 | 13 | def convert_seconds(n: int)->int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | # No test for this exercise. 18 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/244_calculate_area_of_circle.py: -------------------------------------------------------------------------------- 1 | # Title: calculate_area_of_circle 2 | 3 | """ 4 | Given an integer 'n' that represents the radius of a circle, return the area of the circle. 5 | 6 | Hint: the formula to calculate the area of a circle is 3.14 * radius^2 7 | 8 | calculate_area_of_circle(5) -> 78.5 9 | calculate_area_of_circle(2) -> 12.56 10 | calculate_area_of_circle(9) -> 254.34 11 | """ 12 | 13 | def calculate_area_of_circle(n: int)->float: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | # No test for this exercise. 18 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/245_calculate_average.py: -------------------------------------------------------------------------------- 1 | # Title: calculate_average 2 | 3 | """ 4 | Given 3 integers 'n1', 'n2' and 'n3', return the average of those 3 numbers. 5 | 6 | calculate_average(5, 10, 15) -> 10.00 7 | calculate_average(1, 1, 7) -> 3.00 8 | calculate_average(-1, -5, -9) -> - 3.00 9 | """ 10 | 11 | def calculate_average(n1: int, n2: int, n3:int)->float: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | # No test for this exercise. 16 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/246_convert_fahrenheit_to_celsius.py: -------------------------------------------------------------------------------- 1 | # Title: convert_fahrenheit_to_celsius 2 | 3 | """ 4 | Given a float 'n' that represents the temperature in Fahrenheit, return the temperature converted to Celsius. 5 | 6 | Hint: 1 Celsius = (Fahrenheit - 32) * 5/9 7 | 8 | convert_fahrenheit_to_celsius(212) -> 100.0 9 | convert_fahrenheit_to_celsius(194) -> 90.0 10 | convert_fahrenheit_to_celsius(302) -> 150.0 11 | """ 12 | 13 | def convert_fahrenheit_to_celsius(n: float) -> float: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | # No test for this exercise. 18 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/247_convert_celsius_to_kelvin.py: -------------------------------------------------------------------------------- 1 | # Title: convert_celsius_to_kelvin 2 | 3 | """ 4 | Given a float 'n' that represents the temperature in Celsius, return the temperature converted to Kelvin. 5 | 6 | Hint: 1 Kelvin = Celsius + 273.15 7 | 8 | convert_celsius_to_kelvin(100) -> 373.15 9 | convert_celsius_to_kelvin(170) -> 443.15 10 | convert_celsius_to_kelvin(50) -> 323.15 11 | """ 12 | 13 | def convert_celsius_to_kelvin(n: int)->float: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | # No test for this exercise. 18 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/250_convert_lb_to_kg.py: -------------------------------------------------------------------------------- 1 | # Title: convert_lb_to_kg 2 | 3 | """ 4 | Given a float 'n' that represents the weight in pounds (lb), return the weight converted to kilograms (kg). 5 | 6 | Hint: 1 kg = lb * 0.453592 7 | 8 | convert_lb_to_kg(10) -> 4.54 9 | convert_lb_to_kg(180) -> 81.65 10 | convert_lb_to_kg(220) -> 99.79 11 | """ 12 | 13 | def convert_lb_to_kg(lb: int)->float: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | # No test for this exercise. 18 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/279_return_two.py: -------------------------------------------------------------------------------- 1 | # Title: return_two 2 | 3 | """ 4 | This is a problem to get you started on CodingDors. 5 | 6 | On the second line, write 'return 2' (without the single quotes) and click on Run. 7 | 8 | Remember do not use print! All our problems require a return at the end of it. 9 | """ 10 | 11 | def return_two() -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | # No test for this exercise. 16 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/280_return_n.py: -------------------------------------------------------------------------------- 1 | # Title: return_n 2 | 3 | """ 4 | Write a function that takes one argument called 'n' and always returns n back. 5 | 6 | An argument is a fancy programming word for an input. In the background we are sending different inputs to check if the code you wrote is correct. 7 | 8 | For example, 9 | 10 | If the inputs is 2, we expect 2 back. If you don't understand check the "Show Solution" button. 11 | """ 12 | 13 | def return_n(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | # No test for this exercise. 18 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/3_title_movie.py: -------------------------------------------------------------------------------- 1 | # Title: title_movie 2 | 3 | """ 4 | Write a Python function that takes a string 'movie' and returns a new string with every word in the movie name capitalized. For instance, if the movie name is 'the lord of the rings', the function should return 'The Lord Of The Rings'. 5 | 6 | title_movie('the lord of the rings') -> 'The Lord Of The Rings' 7 | 8 | title_movie('star wars') -> 'Star Wars' 9 | """ 10 | 11 | def title_movie(movie: str)-> str: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(title_movie('star wars')) # Output: 'Star Wars' 16 | print(title_movie('once upon a time in hollywood')) # Output: 'Once Upon A Time In Hollywood' 17 | print(title_movie('the godfather')) # Output: 'The Godfather' 18 | print(title_movie('jaws')) # Output: 'Jaws' 19 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/6_remove_whitespace.py: -------------------------------------------------------------------------------- 1 | # Title: remove_whitespace 2 | 3 | """ 4 | Given a string 's', return a new string without leading or trailing whitespace. 5 | 6 | remove_whitespace(" hi there") -> "hi there" 7 | 8 | remove_whitespace("hello world ") -> "hello world" 9 | """ 10 | 11 | def remove_whitespace(s: str)->str: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(remove_whitespace(' hi there')) # Output: 'hi there' 16 | print(remove_whitespace('hello world ')) # Output: 'hello world' 17 | print(remove_whitespace(' python is great ')) # Output: 'python is great' 18 | print(remove_whitespace(' code')) # Output: 'code' 19 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/8_round_floats.py: -------------------------------------------------------------------------------- 1 | # Title: round_floats 2 | 3 | """ 4 | Given a float 'n', return the number with only two decimal places. 5 | 6 | round_floats(3.141) -> 3.14 7 | 8 | round_floats(75.123456) -> 75.12 9 | """ 10 | 11 | def round_floats(n: float)->float: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(round_floats(3.141)) # Output: 3.14 16 | print(round_floats(75.123456)) # Output: 75.12 17 | print(round_floats(0.123456789)) # Output: 0.12 18 | print(round_floats(10.0)) # Output: 10.0 19 | -------------------------------------------------------------------------------- /CodingDors/1_functions_and_variables/9_remove_letter_g.py: -------------------------------------------------------------------------------- 1 | # Title: remove_letter_g 2 | 3 | """ 4 | Write a Python function that takes a string 's' and returns a new string obtained by removing all occurrences of the letter 'g' from the string. For instance, if the string is 'going to the grocery store', the function should return 'oin to the rocery store'. 5 | 6 | remove_letter_g('going to the grocery store') -> 'oin to the rocery store' 7 | """ 8 | 9 | def remove_letter_g(s: str)->str: 10 | return 11 | 12 | # Test your code (copy and past this block of code to test your solution) 13 | print(remove_letter_g('good')) # Output: 'ood' 14 | print(remove_letter_g('i love coding')) # Output: 'i love codin' 15 | print(remove_letter_g('garage')) # Output: 'arae' 16 | print(remove_letter_g('goalg')) # Output: 'oal' 17 | -------------------------------------------------------------------------------- /CodingDors/2_strings/121_first_character.py: -------------------------------------------------------------------------------- 1 | # Title: first_character 2 | 3 | """ 4 | Write a function that returns the first character of a given string. 5 | 6 | first_character('hello') -> 'h' 7 | 8 | first_character('world') -> 'w' 9 | 10 | first_character('CodingDors') -> 'C' 11 | """ 12 | 13 | def first_character(s: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(first_character('hello')) # Output: 'h' 18 | print(first_character('world')) # Output: 'w' 19 | print(first_character('CodingDors')) # Output: 'C' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/122_second_character.py: -------------------------------------------------------------------------------- 1 | # Title: second_character 2 | 3 | """ 4 | Write a function that returns the second character of a given string. 5 | 6 | second_character('hello') -> 'e' 7 | 8 | second_character('world') -> 'o' 9 | 10 | second_character('CodingDors') -> 'o' 11 | """ 12 | 13 | def second_character(s: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(second_character('hello')) # Output: 'e' 18 | print(second_character('world')) # Output: 'o' 19 | print(second_character('CodingDors')) # Output: 'o' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/123_last_character.py: -------------------------------------------------------------------------------- 1 | # Title: last_character 2 | 3 | """ 4 | Write a function that returns the last character of a given string. 5 | 6 | last_character('hello') -> 'o' 7 | 8 | last_character('world') -> 'd' 9 | 10 | last_character('CodingDors') -> 's' 11 | """ 12 | 13 | def last_character(s: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(last_character('hello')) # Output: 'o' 18 | print(last_character('world')) # Output: 'd' 19 | print(last_character('CodingDors')) # Output: 's' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/124_concatenate_strings.py: -------------------------------------------------------------------------------- 1 | # Title: concatenate_strings 2 | 3 | """ 4 | Write a function that concatenates two given strings. 5 | 6 | concatenate_strings('hello', 'world') -> 'helloworld' 7 | 8 | concatenate_strings('Coding', 'Dors') -> 'CodingDors' 9 | 10 | concatenate_strings('apple', 'banana') -> 'applebanana' 11 | """ 12 | 13 | def concatenate_strings(s1: str, s2: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(concatenate_strings('hello', 'world')) # Output: 'helloworld' 18 | print(concatenate_strings('Coding', 'Dors')) # Output: 'CodingDors' 19 | print(concatenate_strings('apple', 'banana')) # Output: 'applebanana' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/125_repeat_string.py: -------------------------------------------------------------------------------- 1 | # Title: repeat_string 2 | 3 | """ 4 | Write a function that repeats a given string n times. 5 | 6 | repeat_string('hi', 3) -> 'hihihi' 7 | 8 | repeat_string('code', 2) -> 'codecode' 9 | 10 | repeat_string('a', 5) -> 'aaaaa' 11 | """ 12 | 13 | def repeat_string(s: str, n: int) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(repeat_string('hi', 3)) # Output: 'hihihi' 18 | print(repeat_string('code', 2)) # Output: 'codecode' 19 | print(repeat_string('a', 5)) # Output: 'aaaaa' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/126_uppercase_first.py: -------------------------------------------------------------------------------- 1 | # Title: uppercase_first 2 | 3 | """ 4 | Write a function that returns the given string with its first character in uppercase. 5 | 6 | uppercase_first('hello') -> 'Hello' 7 | 8 | uppercase_first('coding') -> 'Coding' 9 | 10 | uppercase_first('leo') -> 'Leo' 11 | """ 12 | 13 | def uppercase_first(s: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(uppercase_first('hello')) # Output: 'Hello' 18 | print(uppercase_first('coding')) # Output: 'Coding' 19 | print(uppercase_first('leo')) # Output: 'Leo' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/127_lowercase_first.py: -------------------------------------------------------------------------------- 1 | # Title: lowercase_first 2 | 3 | """ 4 | Write a function that returns the given string with its first character in lowercase. 5 | 6 | lowercase_first('Hello') -> 'hello' 7 | 8 | lowercase_first('CODING') -> 'cODING' 9 | 10 | lowercase_first('LeO') -> 'leO' 11 | """ 12 | 13 | def lowercase_first(s: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(lowercase_first('Hello')) # Output: 'hello' 18 | print(lowercase_first('CODING')) # Output: 'cODING' 19 | print(lowercase_first('LeO')) # Output: 'leO' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/130_replace_char.py: -------------------------------------------------------------------------------- 1 | # Title: replace_char 2 | 3 | """ 4 | Write a function that replaces all occurrences of a specified character in a given string with another character. 5 | 6 | replace_char('hello', 'l', 'w') -> 'hewwo' 7 | 8 | replace_char('APPLE', 'P', 'Z') -> 'AZZLE' 9 | 10 | replace_char('banana', 'a', '4') -> 'b4n4n4' 11 | """ 12 | 13 | def replace_char(s: str, old_char: str, new_char: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(replace_char('hello', 'l', 'w')) # Output: 'hewwo' 18 | print(replace_char('APPLE', 'P', 'Z')) # Output: 'AZZLE' 19 | print(replace_char('banana', 'a', '4')) # Output: 'b4n4n4' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/131_remove_char.py: -------------------------------------------------------------------------------- 1 | # Title: remove_char 2 | 3 | """ 4 | Write a function that removes all occurrences of a specified character in a given string. 5 | 6 | remove_char('hello', 'l') -> 'heo' 7 | 8 | remove_char('apple', 'e') -> 'appl' 9 | 10 | remove_char('BANANA', 'A') -> 'BNN' 11 | """ 12 | 13 | def remove_char(s: str, char_to_remove: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(remove_char('hello', 'l')) # Output: 'heo' 18 | print(remove_char('apple', 'e')) # Output: 'appl' 19 | print(remove_char('BANANA', 'A')) # Output: 'BNN' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/134_string_length.py: -------------------------------------------------------------------------------- 1 | # Title: string_length 2 | 3 | """ 4 | Write a function that returns the length of a given string. 5 | 6 | string_length('hello') -> 5 7 | 8 | string_length('code') -> 4 9 | 10 | string_length('CodingDors') -> 10 11 | """ 12 | 13 | def string_length(s: str) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(string_length('hello')) # Output: 5 18 | print(string_length('code')) # Output: 4 19 | print(string_length('CodingDors')) # Output: 10 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/135_substring.py: -------------------------------------------------------------------------------- 1 | # Title: substring 2 | 3 | """ 4 | Write a function that returns a substring of a given string, starting from the specified start index and ending with the specified end index. 5 | 6 | substring('hello', 1, 2) -> 'el' 7 | 8 | substring('CodingDors', 6, 9) -> 'Dors' 9 | 10 | substring('applebananaorange', 5, 10) -> 'banana' 11 | """ 12 | 13 | def substring(s: str, start: int, end: int) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(substring('hello', 1, 2)) # Output: 'el' 18 | print(substring('CodingDors', 6, 10)) # Output: 'Dors' 19 | print(substring('applebananaorange', 5, 10)) # Output: 'banana' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/137_remove_whitespace_str.py: -------------------------------------------------------------------------------- 1 | # Title: remove_whitespace_str 2 | 3 | """ 4 | Write a function that removes all leading and trailing whitespace from a given string. 5 | 6 | remove_whitespace_str(' hello') -> 'hello' 7 | 8 | remove_whitespace_str('apple ') -> 'apple' 9 | 10 | remove_whitespace_str(' CodingDors ') -> 'CodingDors' 11 | """ 12 | 13 | def remove_whitespace_str(s: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(remove_whitespace_str(' hello')) # Output: 'hello' 18 | print(remove_whitespace_str('apple ')) # Output: 'apple' 19 | print(remove_whitespace_str(' CodingDors ')) # Output: 'CodingDors' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/19_front_back.py: -------------------------------------------------------------------------------- 1 | # Title: front_back 2 | 3 | """ 4 | Given a string 's', return a new string where the first and last chars have been exchanged. 5 | 6 | front_back('code') → 'eodc' 7 | 8 | front_back('a') → 'a' 9 | """ 10 | 11 | def front_back(s: str)-> str: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(front_back('code')) # Output: 'eodc' 16 | print(front_back('abc')) # Output: 'cba' 17 | print(front_back('abcd')) # Output: 'dbca' 18 | print(front_back('hello')) # Output: 'oellh' 19 | print(front_back('programming')) # Output: 'grogramminp' 20 | -------------------------------------------------------------------------------- /CodingDors/2_strings/251_birthdate.py: -------------------------------------------------------------------------------- 1 | # Title: birthdate 2 | 3 | """ 4 | Given two strings 'day' and 'month', return a new string with the birth date. 5 | 6 | Hint: birth date should be in the format 'month/day' 7 | 8 | birthdate('03', '07') -> '07/03' 9 | 10 | birthdate('29', '06') -> '06/29' 11 | 12 | birthdate('01', '05') -> '05/01' 13 | """ 14 | 15 | def birthdate(day: str, month: str) -> str: 16 | return 17 | 18 | # Test your code (copy and past this block of code to test your solution) 19 | print(birthdate('03', '07')) # Output: '07/03' 20 | print(birthdate('29', '06')) # Output: '06/29' 21 | print(birthdate('01', '05')) # Output: '05/01' 22 | print(birthdate('14', '09')) # Output: '09/14' 23 | print(birthdate('28', '02')) # Output: '02/28' 24 | -------------------------------------------------------------------------------- /CodingDors/2_strings/252_formatted_time.py: -------------------------------------------------------------------------------- 1 | # Title: formatted_time 2 | 3 | """ 4 | Given two strings 'hour' and 'minute', return a new string with the formatted time. 5 | 6 | Hint: the time should be in the format 'hour:minute' 7 | 8 | formatted_time('10', '15') -> '10:15' 9 | 10 | formatted_time('05', '30') -> '05:30' 11 | 12 | formatted_time('20', '00') -> '20:00' 13 | """ 14 | 15 | def formatted_time(hour: str, minute: str) -> str: 16 | return 17 | 18 | # Test your code (copy and past this block of code to test your solution) 19 | print(formatted_time('10', '15')) # Output: '10:15' 20 | print(formatted_time('05', '30')) # Output: '05:30' 21 | print(formatted_time('20', '00')) # Output: '20:00' 22 | print(formatted_time('01', '01')) # Output: '01:01' 23 | print(formatted_time('12', '59')) # Output: '12:59' 24 | -------------------------------------------------------------------------------- /CodingDors/2_strings/253_full_name.py: -------------------------------------------------------------------------------- 1 | # Title: full_name 2 | 3 | """ 4 | Given two strings 'firstName' and 'lastName', return a new string with the full name. 5 | 6 | Hint: the full name should be in the format 'firstName lastName' 7 | 8 | full_name('John', 'Doe') -> 'John Doe' 9 | 10 | full_name('Emma', 'Watson') -> 'Emma Watson' 11 | 12 | full_name('Elon', 'Musk') -> 'Elon Musk' 13 | """ 14 | 15 | def full_name(firstName: str, lastName: str) -> str: 16 | return 17 | 18 | # Test your code (copy and past this block of code to test your solution) 19 | print(full_name('John', 'Doe')) # Output: 'John Doe' 20 | print(full_name('Emma', 'Watson')) # Output: 'Emma Watson' 21 | print(full_name('Elon', 'Musk')) # Output: 'Elon Musk' 22 | print(full_name('James', '')) # Output: 'James ' 23 | print(full_name('', 'Smith')) # Output: ' Smith' 24 | -------------------------------------------------------------------------------- /CodingDors/2_strings/254_year_day.py: -------------------------------------------------------------------------------- 1 | # Title: year_day 2 | 3 | """ 4 | Given two strings 'day' and 'year', return a new string with the year and day of the year. 5 | 6 | Hint: the output should be in the format 'year-day' 7 | 8 | year_day('364', '2022') -> '2022-364' 9 | 10 | year_day('1', '2030') -> '2030-1' 11 | 12 | year_day('123', '2021') -> '2021-123' 13 | """ 14 | 15 | def year_day(day: str, year: str) -> str: 16 | return 17 | 18 | # Test your code (copy and past this block of code to test your solution) 19 | print(year_day('364', '2022')) # Output: '2022-364' 20 | print(year_day('1', '2030')) # Output: '2030-1' 21 | print(year_day('123', '2021')) # Output: '2021-123' 22 | print(year_day('30', '2023')) # Output: '2023-30' 23 | print(year_day('6', '2024')) # Output: '2024-6' 24 | print(year_day('5', '2021')) # Output: '2021-5' 25 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/101_is_even.py: -------------------------------------------------------------------------------- 1 | # Title: is_even 2 | 3 | """ 4 | Write a function that checks if a given number is even. 5 | 6 | is_even(5) -> False 7 | 8 | is_even(10) -> True 9 | 10 | is_even(99) -> False 11 | """ 12 | 13 | def is_even(n: int) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_even(5)) # Output: False 18 | print(is_even(10)) # Output: True 19 | print(is_even(99)) # Output: False 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/102_is_positive.py: -------------------------------------------------------------------------------- 1 | # Title: is_positive 2 | 3 | """ 4 | Write a function that checks if a given number is positive. 5 | 6 | is_positive(1) -> True 7 | 8 | is_positive(-10) -> False 9 | 10 | is_positive(19) -> True 11 | """ 12 | 13 | def is_positive(n: int) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_positive(1)) # Output: True 18 | print(is_positive(-10)) # Output: False 19 | print(is_positive(19)) # Output: True 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/103_is_divisible.py: -------------------------------------------------------------------------------- 1 | # Title: is_divisible 2 | 3 | """ 4 | Write a function that checks if a given number is divisible by another number. 5 | 6 | is_divisible(8, 2) -> True 7 | 8 | is_divisible(5, 3) -> False 9 | 10 | is_divisible(21, 7) -> True 11 | """ 12 | 13 | def is_divisible(x: int, y: int) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_divisible(8, 2)) # Output: True 18 | print(is_divisible(5, 3)) # Output: False 19 | print(is_divisible(21, 7)) # Output: True 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/104_maximum.py: -------------------------------------------------------------------------------- 1 | # Title: maximum 2 | 3 | """ 4 | Write a function that returns the maximum of two numbers. 5 | 6 | maximum(1, 3) -> 3 7 | 8 | maximum(7, -3) -> 7 9 | 10 | maximum(10, -10) -> 10 11 | """ 12 | 13 | def maximum(x: int, y: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(maximum(1, 3)) # Output: 3 18 | print(maximum(7, -3)) # Output: 7 19 | print(maximum(10, -10)) # Output: 10 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/105_minimum.py: -------------------------------------------------------------------------------- 1 | # Title: minimum 2 | 3 | """ 4 | Write a function that returns the minimum of two numbers. 5 | 6 | minimum(3, 7) -> 3 7 | 8 | minimum(-3, -7) -> -7 9 | 10 | minimum(10, 110) -> 10 11 | """ 12 | 13 | def minimum(x: int, y: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(minimum(3, 7)) # Output: 3 18 | print(minimum(-3, -7)) # Output: -7 19 | print(minimum(10, 110)) # Output: 10 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/106_absolute_value.py: -------------------------------------------------------------------------------- 1 | # Title: absolute_value 2 | 3 | """ 4 | Write a function that returns the absolute value of a number. 5 | 6 | absolute_value(8) -> 8 7 | 8 | absolute_value(-19) -> 19 9 | 10 | absolute_value(-37) -> 37 11 | """ 12 | 13 | def absolute_value(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(absolute_value(8)) # Output: 8 18 | print(absolute_value(-19)) # Output: 19 19 | print(absolute_value(-37)) # Output: 37 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/107_greater_number.py: -------------------------------------------------------------------------------- 1 | # Title: greater_number 2 | 3 | """ 4 | Write a function that returns the greater number of three given numbers. 5 | 6 | greater_number(1, 2, 3) -> 3 7 | 8 | greater_number(-1, -2, -3) -> -1 9 | 10 | greater_number(10, 15, 7) -> 15 11 | """ 12 | 13 | def greater_number(x: int, y: int, z: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(greater_number(1, 2, 3)) # Output: 3 18 | print(greater_number(-1, -2, -3)) # Output: -1 19 | print(greater_number(10, 15, 7)) # Output: 15 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/108_is_negative.py: -------------------------------------------------------------------------------- 1 | # Title: is_negative 2 | 3 | """ 4 | Write a function that checks if a given number is negative. 5 | 6 | is_negative(5) -> False 7 | 8 | is_negative(-5) -> True 9 | 10 | is_negative(-21) -> True 11 | """ 12 | 13 | def is_negative(n: int) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_negative(5)) # Output: False 18 | print(is_negative(-5)) # Output: True 19 | print(is_negative(-21)) # Output: True 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/109_is_odd.py: -------------------------------------------------------------------------------- 1 | # Title: is_odd 2 | 3 | """ 4 | Write a function that checks if a given number is odd. 5 | 6 | is_odd(8) -> False 7 | 8 | is_odd(9) -> True 9 | 10 | is_odd(-21) -> True 11 | """ 12 | 13 | def is_odd(n: int) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_odd(8)) # Output: False 18 | print(is_odd(9)) # Output: True 19 | print(is_odd(-21)) # Output: True 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/110_is_leap_year.py: -------------------------------------------------------------------------------- 1 | # Title: is_leap_year 2 | 3 | """ 4 | Write a function that checks if a given year is a leap year. 5 | 6 | Hint: A leap year is divisible by 4 but not divisible by 100 7 | 8 | is_leap_year(2020) -> True 9 | 10 | is_leap_year(2021) -> False 11 | 12 | is_leap_year(1996) -> True 13 | """ 14 | 15 | def is_leap_year(year: int) -> bool: 16 | return 17 | 18 | # Test your code (copy and past this block of code to test your solution) 19 | print(is_leap_year(2020)) # Output: True 20 | print(is_leap_year(2021)) # Output: False 21 | print(is_leap_year(1996)) # Output: True 22 | print(is_leap_year(2001)) # Output: False 23 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/111_is_vowel.py: -------------------------------------------------------------------------------- 1 | # Title: is_vowel 2 | 3 | """ 4 | Write a function that checks if a given character is a vowel. 5 | 6 | is_vowel('a') -> True 7 | 8 | is_vowel('b') -> False 9 | 10 | is_vowel('u') -> True 11 | """ 12 | 13 | def is_vowel(char: str) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_vowel('a')) # Output: True 18 | print(is_vowel('b')) # Output: False 19 | print(is_vowel('u')) # Output: True 20 | print(is_vowel('z')) # Output: False 21 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/112_is_consonant.py: -------------------------------------------------------------------------------- 1 | # Title: is_consonant 2 | 3 | """ 4 | Write a function that checks if a given character is a consonant. 5 | 6 | is_consonant('c') -> True 7 | 8 | is_consonant('a') -> False 9 | 10 | is_consonant('z') -> True 11 | """ 12 | 13 | def is_consonant(char: str) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_consonant('c')) # Output: True 18 | print(is_consonant('a')) # Output: False 19 | print(is_consonant('z')) # Output: True 20 | print(is_consonant('o')) # Output: False 21 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/113_is_uppercase.py: -------------------------------------------------------------------------------- 1 | # Title: is_uppercase 2 | 3 | """ 4 | Write a function that checks if a given character is uppercase. 5 | 6 | is_uppercase('a') -> False 7 | 8 | is_uppercase('A') -> True 9 | 10 | is_uppercase('Z') -> True 11 | """ 12 | 13 | def is_uppercase(char: str) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_uppercase('a')) # Output: False 18 | print(is_uppercase('A')) # Output: True 19 | print(is_uppercase('Z')) # Output: True 20 | print(is_uppercase('b')) # Output: False 21 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/114_is_lowercase.py: -------------------------------------------------------------------------------- 1 | # Title: is_lowercase 2 | 3 | """ 4 | Write a function that checks if a given character is lowercase. 5 | 6 | is_lowercase('a') -> True 7 | 8 | is_lowercase('A') -> False 9 | 10 | is_lowercase('z') -> True 11 | """ 12 | 13 | def is_lowercase(char: str) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_lowercase('a')) # Output: True 18 | print(is_lowercase('A')) # Output: False 19 | print(is_lowercase('z')) # Output: True 20 | print(is_lowercase('B')) # Output: False 21 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/115_is_same_letter.py: -------------------------------------------------------------------------------- 1 | # Title: is_same_letter 2 | 3 | """ 4 | Write a function that checks if two given characters are the same letter, regardless of their case. 5 | 6 | is_same_letter('a', 'A') -> True 7 | 8 | is_same_letter('a', 'b') -> False 9 | 10 | is_same_letter('C', 'C') -> True 11 | """ 12 | 13 | def is_same_letter(char1: str, char2: str) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_same_letter('a', 'A')) # Output: True 18 | print(is_same_letter('a', 'b')) # Output: False 19 | print(is_same_letter('C', 'C')) # Output: True 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/116_is_digit.py: -------------------------------------------------------------------------------- 1 | # Title: is_digit 2 | 3 | """ 4 | Write a function that checks if a given character is a digit. 5 | 6 | is_digit(1) -> True 7 | 8 | is_digit('a') -> False 9 | 10 | is_digit('!') -> False 11 | """ 12 | 13 | def is_digit(char: str) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_digit('1')) # Output: True 18 | print(is_digit('a')) # Output: False 19 | print(is_digit('!')) # Output: False 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/117_is_alphabetic.py: -------------------------------------------------------------------------------- 1 | # Title: is_alphabetic 2 | 3 | """ 4 | Write a function that checks if a given character is alphabetic. 5 | 6 | is_alphabetic('g') -> True 7 | 8 | is_alphabetic('1') -> False 9 | 10 | is_alphabetic('?') -> False 11 | """ 12 | 13 | def is_alphabetic(char: str) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_alphabetic('g')) # Output: True 18 | print(is_alphabetic('1')) # Output: False 19 | print(is_alphabetic('?')) # Output: False 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/118_is_alphanumeric.py: -------------------------------------------------------------------------------- 1 | # Title: is_alphanumeric 2 | 3 | """ 4 | Write a function that checks if a given character is alphanumeric. 5 | 6 | is_alphanumeric('a') -> True 7 | 8 | is_alphanumeric('1') -> True 9 | 10 | is_alphanumeric('.') -> False 11 | """ 12 | 13 | def is_alphanumeric(char: str) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_alphanumeric('a')) # Output: True 18 | print(is_alphanumeric('1')) # Output: True 19 | print(is_alphanumeric('.')) # Output: False 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/119_is_greater_or_equal.py: -------------------------------------------------------------------------------- 1 | # Title: is_greater_or_equal 2 | 3 | """ 4 | Write a function that checks if the first given number is greater than or equal to the second given number. 5 | 6 | is_greater_or_equal(3, 3) -> True 7 | 8 | is_greater_or_equal(-10, -21) -> True 9 | 10 | is_greater_or_equal(1, 10) -> False 11 | """ 12 | 13 | def is_greater_or_equal(x: int, y: int) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_greater_or_equal(3, 3)) # Output: True 18 | print(is_greater_or_equal(-10, -21)) # Output: True 19 | print(is_greater_or_equal(1, 10)) # Output: False 20 | -------------------------------------------------------------------------------- /CodingDors/3_conditionals/120_is_smaller_or_equal.py: -------------------------------------------------------------------------------- 1 | # Title: is_smaller_or_equal 2 | 3 | """ 4 | Write a function that checks if the first given number is smaller than or equal to the second given number. 5 | 6 | is_smaller_or_equal(1, 3) -> True 7 | 8 | is_smaller_or_equal(-10, -10) -> True 9 | 10 | is_smaller_or_equal(7, 1) -> False 11 | """ 12 | 13 | def is_smaller_or_equal(x: int, y: int) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(is_smaller_or_equal(1, 3)) # Output: True 18 | print(is_smaller_or_equal(-10, -10)) # Output: True 19 | print(is_smaller_or_equal(7, 1)) # Output: False 20 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/13_sum_or_half_sum.py: -------------------------------------------------------------------------------- 1 | # Title: sum_or_half_sum 2 | 3 | """ 4 | Write a Python function that takes two input integers 'a' and 'b', and returns their sum unless the two values are the same, in which case it should return half of their sum. For instance, if 'a' is 4 and 'b' is 5, the function should return 9. If 'a' and 'b' are both 3, the function should return 3. 5 | 6 | sum_or_half_sum(4, 5) -> 9 7 | 8 | sum_or_half_sum(3, 3) -> 3 9 | """ 10 | 11 | def sum_or_half_sum(a: int, b: int)-> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(sum_or_half_sum((2, 2))) # Output: 2 16 | print(sum_or_half_sum((1, 2))) # Output: 3 17 | print(sum_or_half_sum((-3, -3))) # Output: -3 18 | print(sum_or_half_sum((0, 5))) # Output: 5 19 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/16_near_ten.py: -------------------------------------------------------------------------------- 1 | # Title: near_ten 2 | 3 | """ 4 | Given an int 'n', return True if it is within 10 of 50. 5 | Note: abs(num) computes the absolute value of a number. 6 | 7 | near_ten(48) → True 8 | 9 | near_ten(55) → True 10 | 11 | near_ten(5) → False 12 | """ 13 | 14 | def near_ten(n: int)->bool: 15 | return 16 | 17 | # Test your code (copy and past this block of code to test your solution) 18 | print(near_ten(48)) # Output: True 19 | print(near_ten(55)) # Output: True 20 | print(near_ten(5)) # Output: False 21 | print(near_ten(40)) # Output: True 22 | print(near_ten(60)) # Output: True 23 | print(near_ten(51)) # Output: True 24 | print(near_ten(59)) # Output: True 25 | print(near_ten(61)) # Output: False 26 | print(near_ten(71)) # Output: False 27 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/17_hi_string.py: -------------------------------------------------------------------------------- 1 | # Title: hi_string 2 | 3 | """ 4 | Given a string 's', return a new string where "hi " has been added to the front. However, if the string already begins with "hi", return the string unchanged. 5 | 6 | hi_string('Alice') → 'hi Alice' 7 | 8 | hi_string('hi Bob') → 'hi Bob' 9 | 10 | hi_string('') → 'hi' 11 | """ 12 | 13 | def hi_string(s: str)-> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(hi_string('Alice')) # Output: 'hi Alice' 18 | print(hi_string('hi Bob')) # Output: 'hi Bob' 19 | print(hi_string('hi')) # Output: 'hi' 20 | print(hi_string('story')) # Output: 'hi story' 21 | print(hi_string('hi Anna')) # Output: 'hi Anna' 22 | print(hi_string('Gi')) # Output: 'hi Gi' 23 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/184_love_six.py: -------------------------------------------------------------------------------- 1 | # Title: love_six 2 | 3 | """ 4 | The number 6 is a truly great number. Given two int values, a and b, return True if either one is 6. Or if their sum or difference is 6. 5 | 6 | love_six(6, 4) → True 7 | love_six(4, 5) → False 8 | love_six(1, 5) → True 9 | """ 10 | 11 | def love_six(a: int, b: int) -> bool: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(love_six((6, 4))) # Output: True 16 | print(love_six((4, 5))) # Output: False 17 | print(love_six((1, 5))) # Output: True 18 | print(love_six((12, 6))) # Output: True 19 | print(love_six((6, 6))) # Output: True 20 | print(love_six((2, 8))) # Output: True 21 | print(love_six((9, 3))) # Output: True 22 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/186_near_ten_bool.py: -------------------------------------------------------------------------------- 1 | # Title: near_ten_bool 2 | 3 | """ 4 | Given a non-negative number "num", return True if num is within 2 of a multiple of 10. Note: (a % b) is the remainder of dividing a by b, so (7 % 5) is 2. 5 | 6 | near_ten_bool(12) → True 7 | near_ten_bool(19) → True 8 | near_ten_bool(23) → False 9 | """ 10 | 11 | def near_ten_bool(num: int) -> bool: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(near_ten_bool(12)) # Output: True 16 | print(near_ten_bool(19)) # Output: True 17 | print(near_ten_bool(21)) # Output: True 18 | print(near_ten_bool(8)) # Output: True 19 | print(near_ten_bool(23)) # Output: False 20 | print(near_ten_bool(30)) # Output: True 21 | print(near_ten_bool(31)) # Output: True 22 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/187_teen_sum.py: -------------------------------------------------------------------------------- 1 | # Title: teen_sum 2 | 3 | """ 4 | Given 2 ints, a and b, return their sum. However, "teen" values in the range 13..19 inclusive, are extra lucky. So if either value is a teen, just return 19. 5 | 6 | teen_sum(10, 13) → 19 7 | teen_sum(2, 3) → 5 8 | teen_sum(9, 0) → 9 9 | """ 10 | 11 | def teen_sum(a: int, b: int) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(teen_sum((10, 13))) # Output: 19 16 | print(teen_sum((6, 14))) # Output: 19 17 | print(teen_sum((13, 6))) # Output: 19 18 | print(teen_sum((15, 2))) # Output: 19 19 | print(teen_sum((2, 3))) # Output: 5 20 | print(teen_sum((19, 0))) # Output: 19 21 | print(teen_sum((9, 0))) # Output: 9 22 | print(teen_sum((18, 99))) # Output: 19 23 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/190_fizz_string.py: -------------------------------------------------------------------------------- 1 | # Title: fizz_string 2 | 3 | """ 4 | Given a string str, if the string starts with "f" return "Fizz". If the string ends with "b" return "Buzz". If both the "f" and "b" conditions are true, return "FizzBuzz". In all other cases, return the string unchanged. 5 | 6 | fizz_string('fizz') → 'Fizz' 7 | fizz_string('buzzb') → 'Buzz' 8 | fizz_string('fizzb') → 'FizzBuzz' 9 | fizz_string('abcdefg') → 'abcdefg' 10 | """ 11 | 12 | def fizz_string(s: str) -> str: 13 | return 14 | 15 | # Test your code (copy and past this block of code to test your solution) 16 | print(fizz_string('fizz')) # Output: 'Fizz' 17 | print(fizz_string('buzzb')) # Output: 'Buzz' 18 | print(fizz_string('fizzb')) # Output: 'FizzBuzz' 19 | print(fizz_string('abcdefg')) # Output: 'abcdefg' 20 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/194_max_mod5.py: -------------------------------------------------------------------------------- 1 | # Title: max_mod5 2 | 3 | """ 4 | Given two int values, return whichever value is larger. However, if the two values have the same remainder when divided by 5, then the return the smaller value. However, in all cases, if the two values are the same, return 0. 5 | 6 | max_mod5(10, 5) → 5 7 | max_mod5(20, 15) → 15 8 | max_mod5(10, 10) → 0 9 | """ 10 | 11 | def max_mod5(a: int, b: int) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(max_mod5((10, 5))) # Output: 5 16 | print(max_mod5((20, 15))) # Output: 15 17 | print(max_mod5((10, 10))) # Output: 0 18 | print(max_mod5((6, 3))) # Output: 6 19 | print(max_mod5((18, 22))) # Output: 22 20 | -------------------------------------------------------------------------------- /CodingDors/4_conditionals2/20_front5.py: -------------------------------------------------------------------------------- 1 | # Title: front5 2 | 3 | """ 4 | Given a string 's', we'll say that the front is the first 5 chars of the string. If the string length is less than 5, the front is whatever is there. Return a new string which is 5 copies of the front. 5 | 6 | front5('Python') → 'PythoPythoPythoPythoPytho' 7 | 8 | front5('Chocolate') → 'ChocoChocoChocoChocoChoco' 9 | 10 | front5('abc') → 'abcabcabcabcabc' 11 | """ 12 | 13 | def front5(s: str)-> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(front5('Python')) # Output: 'PythoPythoPythoPythoPytho' 18 | print(front5('Chocolate')) # Output: 'ChocoChocoChocoChocoChoco' 19 | print(front5('abc')) # Output: 'abcabcabcabcabc' 20 | print(front5('ab')) # Output: 'ababababab' 21 | print(front5('a')) # Output: 'aaaaa' 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/257_first_element.py: -------------------------------------------------------------------------------- 1 | # Title: first_element 2 | 3 | """ 4 | Write a function that returns the first element of a given list. 5 | 6 | first_element([1,2,3,4,5]) -> 1 7 | 8 | first_element([5,4,3,2,1]) -> 5 9 | 10 | first_element([10,20,30,40,50]) -> 10 11 | """ 12 | 13 | def first_element(n: list) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(first_element([1, 2, 3, 4, 5])) # Output: 1 18 | print(first_element([5, 4, 3, 2, 1])) # Output: 5 19 | print(first_element([10, 20, 30, 40, 50])) # Output: 10 20 | print(first_element([7, 8, 9])) # Output: 7 21 | print(first_element([-1, -2, -3, -4, -5])) # Output: -1 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/258_second_element.py: -------------------------------------------------------------------------------- 1 | # Title: second_element 2 | 3 | """ 4 | Write a function that returns the second element of a given list. 5 | 6 | second_element([1,2,3,4,5]) -> 2 7 | 8 | second_element([5,4,3,2,1]) -> 4 9 | 10 | second_element([10,20,30,40,50]) -> 20 11 | """ 12 | 13 | def second_element(n: list) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(second_element([1, 2, 3, 4, 5])) # Output: 2 18 | print(second_element([5, 4, 3, 2, 1])) # Output: 4 19 | print(second_element([10, 20, 30, 40, 50])) # Output: 20 20 | print(second_element([7, 8, 9])) # Output: 8 21 | print(second_element([-1, -2, -3, -4, -5])) # Output: -2 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/259_last_element.py: -------------------------------------------------------------------------------- 1 | # Title: last_element 2 | 3 | """ 4 | Write a function that returns the last element of a given list. 5 | 6 | last_element([1,2,3,4,5]) -> 5 7 | 8 | last_element([5,4,3,2,1]) -> 1 9 | 10 | last_element([10,20,30,40,50]) -> 50 11 | """ 12 | 13 | def last_element(n: list) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(last_element([1, 2, 3, 4, 5])) # Output: 5 18 | print(last_element([5, 4, 3, 2, 1])) # Output: 1 19 | print(last_element([10, 20, 30, 40, 50])) # Output: 50 20 | print(last_element([7, 8, 9])) # Output: 9 21 | print(last_element([-1, -2, -3, -4, -5])) # Output: -5 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/260_list_length.py: -------------------------------------------------------------------------------- 1 | # Title: list_length 2 | 3 | """ 4 | Write a function that returns the length of a given list. 5 | 6 | list_length([2,5,8]) -> 3 7 | 8 | list_length([11,3,2,9]) -> 4 9 | 10 | list_length([0,2,4,6,8,9]) -> 6 11 | """ 12 | 13 | def list_length(n: list) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(list_length([2, 5, 8])) # Output: 3 18 | print(list_length([11, 3, 2, 9])) # Output: 4 19 | print(list_length([0, 2, 4, 6, 8, 9])) # Output: 6 20 | print(list_length([7, 8, 9])) # Output: 3 21 | print(list_length([-1, -2, -3, -4, -5])) # Output: 5 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/261_concatenate_lists.py: -------------------------------------------------------------------------------- 1 | # Title: concatenate_lists 2 | 3 | """ 4 | Write a function that concatenates two given lists. 5 | 6 | concatenate_lists([1], [2]) -> [1,2] 7 | 8 | concatenate_lists([3,4], [5]) -> [3,4,5] 9 | 10 | concatenate_lists([2], [4,6,8]) -> [2,4,6,8] 11 | """ 12 | 13 | def concatenate_lists(n1: list, n2: list) -> list: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(concatenate_lists(([1], [2]))) # Output: [1, 2] 18 | print(concatenate_lists(([3, 4], [5]))) # Output: [3, 4, 5] 19 | print(concatenate_lists(([2], [4, 6, 8]))) # Output: [2, 4, 6, 8] 20 | print(concatenate_lists(([1, 3, 5], [2, 4, 6]))) # Output: [1, 3, 5, 2, 4, 6] 21 | print(concatenate_lists(([], [1, 2, 3]))) # Output: [1, 2, 3] 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/262_repeat_list.py: -------------------------------------------------------------------------------- 1 | # Title: repeat_list 2 | 3 | """ 4 | Write a function that repeats a given list n times. 5 | 6 | repeat_list([1,2], 3) -> [1,2,1,2,1,2] 7 | 8 | repeat_list([5,6,7]], 2) -> [5,6,7,5,6,7] 9 | 10 | repeat_list([1], 5) -> [1,1,1,1,1] 11 | """ 12 | 13 | def repeat_list(l: list, n: int) -> list: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(repeat_list(([1, 2], 3))) # Output: [1, 2, 1, 2, 1, 2] 18 | print(repeat_list(([5, 6, 7], 2))) # Output: [5, 6, 7, 5, 6, 7] 19 | print(repeat_list(([1], 5))) # Output: [1, 1, 1, 1, 1] 20 | print(repeat_list(([1, 2, 3, 4], 2))) # Output: [1, 2, 3, 4, 1, 2, 3, 4] 21 | print(repeat_list(([], 3))) # Output: [] 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/263_front_back_list.py: -------------------------------------------------------------------------------- 1 | # Title: front_back_list 2 | 3 | """ 4 | Given a list 'n', return a new list where the first and last elements have been exchanged. 5 | 6 | front_back_list([10,20,30]) → [30,20,10] 7 | 8 | front_back_list([5,6,7]) → [7,6,5] 9 | 10 | front_back_list([4,6,8]) → [8,6,4] 11 | """ 12 | 13 | def front_back_list(n: list) -> list: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(front_back_list([10, 20, 30])) # Output: [30, 20, 10] 18 | print(front_back_list([5, 6, 7])) # Output: [7, 6, 5] 19 | print(front_back_list([4, 6, 8])) # Output: [8, 6, 4] 20 | print(front_back_list([1, 2, 3])) # Output: [3, 2, 1] 21 | print(front_back_list([-1, -2, -3])) # Output: [-3, -2, -1] 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/264_first_element_is_greater.py: -------------------------------------------------------------------------------- 1 | # Title: first_element_is_greater 2 | 3 | """ 4 | Write a function that checks if the first given element in the list is greater than or equal to the second given element. 5 | 6 | first_element_is_greater([4,5]) -> True 7 | 8 | first_element_is_greater([10, -10]) -> True 9 | 10 | first_element_is_greater([1, 10]) -> False 11 | """ 12 | 13 | def first_element_is_greater(n: list) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(first_element_is_greater([4, 5])) # Output: False 18 | print(first_element_is_greater([10, -10])) # Output: True 19 | print(first_element_is_greater([1, 10])) # Output: False 20 | print(first_element_is_greater([5, 3])) # Output: True 21 | print(first_element_is_greater([-1, 1])) # Output: False 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/265_first_element_is_smaller.py: -------------------------------------------------------------------------------- 1 | # Title: first_element_is_smaller 2 | 3 | """ 4 | Write a function that checks if the first given element of the list is smaller than or equal to the second given element. 5 | 6 | first_element_is_smaller([1, 3]) -> True 7 | 8 | first_element_is_smaller([-10, -10]) -> True 9 | 10 | first_element_is_smaller([7, 1]) -> False 11 | """ 12 | 13 | def first_element_is_smaller(n: list) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(first_element_is_smaller([1, 3])) # Output: True 18 | print(first_element_is_smaller([-10, -10])) # Output: True 19 | print(first_element_is_smaller([7, 1])) # Output: False 20 | print(first_element_is_smaller([2, 5])) # Output: True 21 | print(first_element_is_smaller([5, -5])) # Output: False 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/266_first_last9.py: -------------------------------------------------------------------------------- 1 | # Title: first_last9 2 | 3 | """ 4 | Given a list of integers, return True if the number 9 appears as either the first or last element in the list. The list will be of length 1 or more. 5 | 6 | first_last9([1, 2, 9]) → True 7 | 8 | first_last9([9, 1, 2, 3]) → True 9 | 10 | first_last9([13, 9, 1, 2, 3]) → False 11 | """ 12 | 13 | def first_last9(n: list) -> bool: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(first_last9([1, 2, 9])) # Output: True 18 | print(first_last9([9, 1, 2, 3])) # Output: True 19 | print(first_last9([13, 9, 1, 2, 3])) # Output: False 20 | print(first_last9([9, 5, 5, 5, 9])) # Output: True 21 | print(first_last9([3, 2, 1])) # Output: False 22 | -------------------------------------------------------------------------------- /CodingDors/5_lists/267_same_value.py: -------------------------------------------------------------------------------- 1 | # Title: same_value 2 | 3 | """ 4 | Given a list of integers with 3 elements, return True if all the 3 elements are equal. 5 | 6 | 7 | same_value([1, 2, 3]) → False 8 | same_value([2, 2, 2]) → True 9 | same_value([1, 2, 1]) → False 10 | """ 11 | 12 | def same_value(n: list) -> bool: 13 | return 14 | 15 | # Test your code (copy and past this block of code to test your solution) 16 | print(same_value([1, 2, 3])) # Output: False 17 | print(same_value([2, 2, 2])) # Output: True 18 | print(same_value([1, 2, 1])) # Output: False 19 | print(same_value([5, 5, 5])) # Output: True 20 | print(same_value([1, 1, 2])) # Output: False 21 | -------------------------------------------------------------------------------- /CodingDors/5_lists/269_sum_all.py: -------------------------------------------------------------------------------- 1 | # Title: sum_all 2 | 3 | """ 4 | Given a list of integers length 3, return the sum of all the elements. 5 | 6 | 7 | sum_all([1, 2, 3]) → 6 8 | sum_all([5, 11, 2]) → 18 9 | sum_all([7, 0, 0]) → 7 10 | """ 11 | 12 | def sum_all(n: list) -> int: 13 | return 14 | 15 | # Test your code (copy and past this block of code to test your solution) 16 | print(sum_all([1, 2, 3])) # Output: 6 17 | print(sum_all([5, 11, 2])) # Output: 18 18 | print(sum_all([7, 0, 0])) # Output: 7 19 | print(sum_all([4, 3, 2])) # Output: 9 20 | print(sum_all([2, 4, 6])) # Output: 12 21 | -------------------------------------------------------------------------------- /CodingDors/5_lists/270_new_list.py: -------------------------------------------------------------------------------- 1 | # Title: new_list 2 | 3 | """ 4 | Given three individual integers 'a', 'b', and 'c', the task is to formulate a list where each of these integers becomes an element. 5 | 6 | new_list(3, 4, 5) -> [3, 4, 5] 7 | new_list(1, 6, 12) -> [1, 6, 12] 8 | new_list(21, 7, 14) -> [21, 7, 14] 9 | """ 10 | 11 | def new_list(a: int, b: int, c: int) -> list: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(new_list((3, 4, 5))) # Output: [3, 4, 5] 16 | print(new_list((1, 6, 12))) # Output: [1, 6, 12] 17 | print(new_list((21, 7, 14))) # Output: [21, 7, 14] 18 | print(new_list((-1, 0, 1))) # Output: [-1, 0, 1] 19 | print(new_list((10, 20, 30))) # Output: [10, 20, 30] 20 | -------------------------------------------------------------------------------- /CodingDors/5_lists/271_rotate_right.py: -------------------------------------------------------------------------------- 1 | # Title: rotate_right 2 | 3 | """ 4 | Given a list of integers length 3, return a new list with the elements "rotated right" so [1, 2, 3] yields [3, 1, 2]. 5 | 6 | 7 | rotate_right([1, 2, 3]) → [3, 1, 2] 8 | rotate_right([5, 11, 9]) → [9, 5, 11] 9 | rotate_right([7, 0, 0]) → [0, 7, 0] 10 | """ 11 | 12 | def rotate_right(n: list) -> list: 13 | return 14 | 15 | # Test your code (copy and past this block of code to test your solution) 16 | print(rotate_right([1, 2, 3])) # Output: [3, 1, 2] 17 | print(rotate_right([5, 11, 9])) # Output: [9, 5, 11] 18 | print(rotate_right([7, 0, 0])) # Output: [0, 7, 0] 19 | print(rotate_right([3, 2, 1])) # Output: [1, 3, 2] 20 | print(rotate_right([10, 20, 30])) # Output: [30, 10, 20] 21 | -------------------------------------------------------------------------------- /CodingDors/5_lists/272_reverse_list.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_list 2 | 3 | """ 4 | Given a list of integers length 3, return a new list with the elements in reverse order, so [1, 2, 3] becomes [3, 2, 1]. 5 | 6 | 7 | reverse_list([1, 2, 3]) → [3, 2, 1] 8 | reverse_list([5, 11, 9]) → [9, 11, 5] 9 | reverse_list([7, 0, 0]) → [0, 0, 7] 10 | """ 11 | 12 | def reverse_list(n: list) -> list: 13 | return 14 | 15 | # Test your code (copy and past this block of code to test your solution) 16 | print(reverse_list([1, 2, 3])) # Output: [3, 2, 1] 17 | print(reverse_list([5, 11, 9])) # Output: [9, 11, 5] 18 | print(reverse_list([7, 0, 0])) # Output: [0, 0, 7] 19 | print(reverse_list([3, 2, 1])) # Output: [1, 2, 3] 20 | print(reverse_list([10, 20, 30])) # Output: [30, 20, 10] 21 | -------------------------------------------------------------------------------- /CodingDors/5_lists/273_min_end.py: -------------------------------------------------------------------------------- 1 | # Title: min_end 2 | 3 | """ 4 | Given a list of integers length 3, figure out which is smaller, the first, second or last element in the list, and set all the other elements to be that value. Return the changed list. 5 | 6 | 7 | min_end([1, 2, 3]) → [1, 1, 1] 8 | min_end([11, 5, 9]) → [5, 5, 5] 9 | min_end([2, 11, 3]) → [2, 2, 2] 10 | """ 11 | 12 | def min_end(n: list) -> list: 13 | return 14 | 15 | # Test your code (copy and past this block of code to test your solution) 16 | print(min_end([1, 2, 3])) # Output: [1, 1, 1] 17 | print(min_end([11, 5, 9])) # Output: [5, 5, 5] 18 | print(min_end([2, 11, 3])) # Output: [2, 2, 2] 19 | print(min_end([4, 3, 2])) # Output: [2, 2, 2] 20 | print(min_end([2, 4, 6])) # Output: [2, 2, 2] 21 | -------------------------------------------------------------------------------- /CodingDors/5_lists/276_even_list.py: -------------------------------------------------------------------------------- 1 | # Title: even_list 2 | 3 | """ 4 | Given a list of integers length 3, return True if all the elements are even. 5 | 6 | even_list([2, 5, 6]) → False 7 | even_list([4, 8, 12]) → True 8 | even_list([1, 3, 9]) → False 9 | """ 10 | 11 | def even_list(n: list) -> bool: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(even_list([2, 5, 6])) # Output: False 16 | print(even_list([4, 8, 12])) # Output: True 17 | print(even_list([1, 3, 9])) # Output: False 18 | print(even_list([2, 4, 6])) # Output: True 19 | print(even_list([3, 5, 7])) # Output: False 20 | -------------------------------------------------------------------------------- /CodingDors/6_loops/21_return_quarters.py: -------------------------------------------------------------------------------- 1 | # Title: return_quarters 2 | 3 | """ 4 | Given an integer called 'change', use a while loop to determine how many quarters will be given as 'change'. 5 | 6 | return_quarters(76) -> 3 7 | 8 | return_quarters(29) -> 1 9 | """ 10 | 11 | def return_quarters(change: int) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(return_quarters(76)) # Output: 3 16 | print(return_quarters(29)) # Output: 1 17 | print(return_quarters(100)) # Output: 4 18 | print(return_quarters(15)) # Output: 0 19 | print(return_quarters(-5)) # Output: 0 20 | -------------------------------------------------------------------------------- /CodingDors/6_loops/22_sum_sequence.py: -------------------------------------------------------------------------------- 1 | # Title: sum_sequence 2 | 3 | """ 4 | Given 2 integers 'x' and 'y', return the sum of all integers in the range of x and y. 5 | 6 | sum_sequence(1, 100) -> 5050 7 | 8 | sum_sequence(5, 36) -> 501 9 | """ 10 | 11 | def sum_sequence(x: int, y: int) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(sum_sequence((1, 100))) # Output: 5050 16 | print(sum_sequence((5, 36))) # Output: 656 17 | print(sum_sequence((-10, 10))) # Output: 0 18 | print(sum_sequence((-5, 5))) # Output: 0 19 | print(sum_sequence((0, 0))) # Output: 0 20 | -------------------------------------------------------------------------------- /CodingDors/6_loops/23_count_digits.py: -------------------------------------------------------------------------------- 1 | # Title: count_digits 2 | 3 | """ 4 | Given a integer 'n', return how many digits 'n' has. 5 | 6 | count_digits(3278) -> 4 7 | 8 | count_digits(67766776) -> 8 9 | """ 10 | 11 | def count_digits(n: int) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(count_digits(3278)) # Output: 4 16 | print(count_digits(67766776)) # Output: 8 17 | print(count_digits(3)) # Output: 1 18 | print(count_digits(12345)) # Output: 5 19 | print(count_digits(1000000000)) # Output: 10 20 | -------------------------------------------------------------------------------- /CodingDors/6_loops/24_sum_digits.py: -------------------------------------------------------------------------------- 1 | # Title: sum_digits 2 | 3 | """ 4 | Given a integer 'n', return the sum of the digits. 5 | 6 | sum_digits(3278) -> 20 7 | 8 | sum_digits(67766776) -> 52 9 | """ 10 | 11 | def sum_digits(n: int) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(sum_digits(3278)) # Output: 20 16 | print(sum_digits(67766776)) # Output: 52 17 | print(sum_digits(12345)) # Output: 15 18 | print(sum_digits(1000000000)) # Output: 1 19 | -------------------------------------------------------------------------------- /CodingDors/6_loops/25_sum_every_other_digit.py: -------------------------------------------------------------------------------- 1 | # Title: sum_every_other_digit 2 | 3 | """ 4 | Given an integer 'n', return the sum of every other digit starting from the last digit. 5 | 6 | sum_every_other_digit(3278) -> 10 7 | 8 | sum_every_other_digit(1039) -> 9 9 | """ 10 | 11 | def sum_every_other_digit(n: int) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(sum_every_other_digit(3278)) # Output: 10 16 | print(sum_every_other_digit(1039)) # Output: 9 17 | print(sum_every_other_digit(12345)) # Output: 9 18 | print(sum_every_other_digit(1000000000)) # Output: 0 19 | -------------------------------------------------------------------------------- /CodingDors/6_loops/26_sum_every_other_digit_two.py: -------------------------------------------------------------------------------- 1 | # Title: sum_every_other_digit_two 2 | 3 | """ 4 | Given an integer 'n', return the sum of every other digit starting from second to last digit. 5 | 6 | sum_every_other_digit_two(3278) -> 10 7 | 8 | sum_every_other_digit_two(1039) -> 4 9 | """ 10 | 11 | def sum_every_other_digit_two(n: int) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(sum_every_other_digit_two(3278)) # Output: 10 16 | print(sum_every_other_digit_two(1039)) # Output: 4 17 | print(sum_every_other_digit_two(12345)) # Output: 6 18 | print(sum_every_other_digit_two(1000000000)) # Output: 1 19 | -------------------------------------------------------------------------------- /CodingDors/6_loops/294_sum_to_n_even.py: -------------------------------------------------------------------------------- 1 | # Title: sum_to_n_even 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum of all even integers from 0 to n inclusive, using a for loop. 5 | 6 | sum_to_n_even(5) -> 6 7 | 8 | sum_to_n_even(10) -> 30 9 | 10 | sum_to_n_even(1) -> 0 11 | """ 12 | 13 | def sum_to_n_even(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_to_n_even(5)) # Output: 6 18 | print(sum_to_n_even(10)) # Output: 30 19 | print(sum_to_n_even(1)) # Output: 0 20 | print(sum_to_n_even(3)) # Output: 2 21 | -------------------------------------------------------------------------------- /CodingDors/6_loops/295_sum_odd_to_n_forloop.py: -------------------------------------------------------------------------------- 1 | # Title: sum_odd_to_n_forloop 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum of all odd integers from 0 to n inclusive, using a for loop. 5 | 6 | sum_odd_to_n_forloop(5) -> 9 7 | 8 | sum_odd_to_n_forloop(10) -> 25 9 | 10 | sum_odd_to_n_forloop(1) -> 1 11 | """ 12 | 13 | def sum_odd_to_n_forloop(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_odd_to_n_forloop(5)) # Output: 9 18 | print(sum_odd_to_n_forloop(10)) # Output: 25 19 | print(sum_odd_to_n_forloop(1)) # Output: 1 20 | print(sum_odd_to_n_forloop(3)) # Output: 4 21 | print(sum_odd_to_n_forloop(15)) # Output: 64 22 | -------------------------------------------------------------------------------- /CodingDors/6_loops/296_sum_even_number_while.py: -------------------------------------------------------------------------------- 1 | # Title: sum_even_number_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum all even integers from 0 to n inclusive, using a while loop. 5 | 6 | sum_even_number_while(5) -> 6 7 | 8 | sum_even_number_while(10) -> 30 9 | 10 | sum_even_number_while(1) -> 0 11 | """ 12 | 13 | def sum_even_number_while(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_even_number_while(5)) # Output: 6 18 | print(sum_even_number_while(10)) # Output: 30 19 | print(sum_even_number_while(1)) # Output: 0 20 | print(sum_even_number_while(3)) # Output: 2 21 | -------------------------------------------------------------------------------- /CodingDors/6_loops/297_sum_to_n_odd_while.py: -------------------------------------------------------------------------------- 1 | # Title: sum_to_n_odd_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum of all odd integers from 0 to n inclusive, using a while loop. 5 | 6 | sum_to_n_odd_while(5) -> 9 7 | 8 | sum_to_n_odd_while(10) -> 25 9 | 10 | sum_to_n_odd_while(1) -> 1 11 | """ 12 | 13 | def sum_to_n_odd_while(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_to_n_odd_while(5)) # Output: 9 18 | print(sum_to_n_odd_while(10)) # Output: 25 19 | print(sum_to_n_odd_while(1)) # Output: 1 20 | print(sum_to_n_odd_while(3)) # Output: 4 21 | print(sum_to_n_odd_while(15)) # Output: 64 22 | -------------------------------------------------------------------------------- /CodingDors/6_loops/298_sum_reverse_n_for.py: -------------------------------------------------------------------------------- 1 | # Title: sum_reverse_n_for 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum of all numbers from n to 0 inclusive (reverse order), using a for loop. 5 | 6 | sum_reverse_n_for(5) -> 15 7 | 8 | sum_reverse_n_for(3) -> 6 9 | 10 | sum_reverse_n_for(1) -> 1 11 | """ 12 | 13 | def sum_reverse_n_for(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_reverse_n_for(5)) # Output: 15 18 | print(sum_reverse_n_for(3)) # Output: 6 19 | print(sum_reverse_n_for(1)) # Output: 1 20 | -------------------------------------------------------------------------------- /CodingDors/6_loops/299_sum_reverse_n_while.py: -------------------------------------------------------------------------------- 1 | # Title: sum_reverse_n_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum all numbers from n to 0 inclusive (reverse order), using a while loop. 5 | 6 | sum_reverse_n_while(5) -> 15 7 | 8 | sum_reverse_n_while(3) -> 6 9 | 10 | sum_reverse_n_while(1) -> 1 11 | """ 12 | 13 | def sum_reverse_n_while(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_reverse_n_while(5)) # Output: 15 18 | print(sum_reverse_n_while(3)) # Output: 6 19 | print(sum_reverse_n_while(1)) # Output: 1 20 | -------------------------------------------------------------------------------- /CodingDors/6_loops/300_sum_reverse_n_even_for.py: -------------------------------------------------------------------------------- 1 | # Title: sum_reverse_n_even_for 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum of all even numbers from n to 0 inclusive, using a for loop. 5 | 6 | sum_reverse_n_even_for(5) -> 6 7 | 8 | sum_reverse_n_even_for(3) -> 2 9 | 10 | sum_reverse_n_even_for(1) -> 0 11 | """ 12 | 13 | def sum_reverse_n_even_for(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_reverse_n_even_for(5)) # Output: 6 18 | print(sum_reverse_n_even_for(10)) # Output: 30 19 | print(sum_reverse_n_even_for(1)) # Output: 0 20 | print(sum_reverse_n_even_for(3)) # Output: 2 21 | -------------------------------------------------------------------------------- /CodingDors/6_loops/301_sum_reverse_n_even_while.py: -------------------------------------------------------------------------------- 1 | # Title: sum_reverse_n_even_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum of all even numbers from n to 0 inclusive, using a while loop. 5 | 6 | sum_reverse_n_even_while(5) -> 6 7 | 8 | sum_reverse_n_even_while(3) -> 2 9 | 10 | sum_reverse_n_even_while(1) -> 0 11 | """ 12 | 13 | def sum_reverse_n_even_while(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_reverse_n_even_while(5)) # Output: 6 18 | print(sum_reverse_n_even_while(10)) # Output: 30 19 | print(sum_reverse_n_even_while(1)) # Output: 0 20 | print(sum_reverse_n_even_while(3)) # Output: 2 21 | -------------------------------------------------------------------------------- /CodingDors/6_loops/302_sum_reverse_n_odd_while.py: -------------------------------------------------------------------------------- 1 | # Title: sum_reverse_n_odd_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum of all odd numbers from n to 1 inclusive, using a while loop. 5 | 6 | sum_reverse_n_odd_while(5) -> 9 7 | 8 | sum_reverse_n_odd_while(3) -> 4 9 | 10 | sum_reverse_n_odd_while(1) -> 1 11 | """ 12 | 13 | def sum_reverse_n_odd_while(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_reverse_n_odd_while(5)) # Output: 9 18 | print(sum_reverse_n_odd_while(10)) # Output: 25 19 | print(sum_reverse_n_odd_while(1)) # Output: 1 20 | print(sum_reverse_n_odd_while(3)) # Output: 4 21 | print(sum_reverse_n_odd_while(15)) # Output: 64 22 | -------------------------------------------------------------------------------- /CodingDors/6_loops/303_sum_reverse_n_odd_for.py: -------------------------------------------------------------------------------- 1 | # Title: sum_reverse_n_odd_for 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns the sum of all odd numbers from n to 0, using a for loop. 5 | 6 | sum_reverse_n_odd_for(5) -> 9 7 | 8 | sum_reverse_n_odd_for(3) -> 4 9 | 10 | sum_reverse_n_odd_for(1) -> 1 11 | """ 12 | 13 | def sum_reverse_n_odd_for(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_reverse_n_odd_for(5)) # Output: 9 18 | print(sum_reverse_n_odd_for(10)) # Output: 25 19 | print(sum_reverse_n_odd_for(1)) # Output: 1 20 | print(sum_reverse_n_odd_for(3)) # Output: 4 21 | print(sum_reverse_n_odd_for(15)) # Output: 64 22 | -------------------------------------------------------------------------------- /CodingDors/6_loops/304_sum_one_to_n_step.py: -------------------------------------------------------------------------------- 1 | # Title: sum_one_to_n_step 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and calculates the sum of all integers from 3 to n, inclusive using a for loop. The function should the return the result. 5 | 6 | sum_one_to_n_step(15) -> 45 7 | 8 | sum_one_to_n_step(10) -> 18 9 | 10 | sum_one_to_n_step(20) -> 63 11 | """ 12 | 13 | def sum_one_to_n_step(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_one_to_n_step(15)) # Output: 45 18 | print(sum_one_to_n_step(10)) # Output: 18 19 | print(sum_one_to_n_step(20)) # Output: 63 20 | print(sum_one_to_n_step(3)) # Output: 3 21 | -------------------------------------------------------------------------------- /CodingDors/6_loops/305_sum_one_to_n_step_while.py: -------------------------------------------------------------------------------- 1 | # Title: sum_one_to_n_step_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and calculates the sum of all integers from 3 to n, inclusive using a while loop. The function should the return the result. 5 | 6 | sum_one_to_n_step_while(15) -> 45 7 | 8 | sum_one_to_n_step_while(10) -> 18 9 | 10 | sum_one_to_n_step_while(20) -> 63 11 | """ 12 | 13 | def sum_one_to_n_step_while(n: int) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_one_to_n_step_while(15)) # Output: 45 18 | print(sum_one_to_n_step_while(10)) # Output: 18 19 | print(sum_one_to_n_step_while(20)) # Output: 63 20 | print(sum_one_to_n_step_while(3)) # Output: 3 21 | -------------------------------------------------------------------------------- /CodingDors/6_loops/83_sum_one_to_n.py: -------------------------------------------------------------------------------- 1 | # Title: sum_one_to_n 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and calculates the sum of all integers from 1 to n, inclusive using a for loop. The function should the return the result. 5 | 6 | sum_one_to_n(5) -> 15 7 | 8 | sum_one_to_n(10) -> 55 9 | 10 | sum_one_to_n(20) -> 210 11 | """ 12 | 13 | def sum_one_to_n(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_one_to_n(5)) # Output: 15 18 | print(sum_one_to_n(10)) # Output: 55 19 | print(sum_one_to_n(20)) # Output: 210 20 | -------------------------------------------------------------------------------- /CodingDors/6_loops/87_sum_one_to_n_while.py: -------------------------------------------------------------------------------- 1 | # Title: sum_one_to_n_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and calculates the sum of all integers from 1 to n, inclusive, using a while loop. 5 | 6 | sum_one_to_n_while(5) -> 15 7 | 8 | sum_one_to_n_while(10) -> 55 9 | 10 | sum_one_to_n_while(20) -> 210 11 | """ 12 | 13 | def sum_one_to_n_while(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(sum_one_to_n_while(5)) # Output: 15 18 | print(sum_one_to_n_while(10)) # Output: 55 19 | print(sum_one_to_n_while(20)) # Output: 210 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/128_count_vowels_str.py: -------------------------------------------------------------------------------- 1 | # Title: count_vowels_str 2 | 3 | """ 4 | Write a function that counts the number of vowels in a given string. 5 | 6 | count_vowels_str('hello') -> 2 7 | 8 | count_vowels_str('codingDORS') -> 3 9 | 10 | count_vowels_str('APPLEbanana') -> 5 11 | """ 12 | 13 | def count_vowels_str(s: str) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(count_vowels_str('hello')) # Output: 2 18 | print(count_vowels_str('codingDORS')) # Output: 3 19 | print(count_vowels_str('APPLEbanana')) # Output: 5 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/129_count_consonants_str.py: -------------------------------------------------------------------------------- 1 | # Title: count_consonants_str 2 | 3 | """ 4 | Write a function that counts the number of consonants in a given string. 5 | 6 | count_consonants_str('hello') -> 3 7 | 8 | count_consonants_str('codingDORS') -> 7 9 | 10 | count_consonants_str('APPLEbanana') -> 6 11 | """ 12 | 13 | def count_consonants_str(s: str) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(count_consonants_str('hello')) # Output: 3 18 | print(count_consonants_str('codingDORS')) # Output: 7 19 | print(count_consonants_str('APPLEbanana')) # Output: 6 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/132_find_char.py: -------------------------------------------------------------------------------- 1 | # Title: find_char 2 | 3 | """ 4 | Write a function that returns the index of the first occurrence of a specified character in a given string or -1 if the character is not present. 5 | 6 | find_char('banana', 'b') -> 0 7 | 8 | find_char('hello', 'l') -> 2 9 | 10 | find_char('code', 'a') -> -1 11 | """ 12 | 13 | def find_char(s: str, char_to_find: str) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(find_char('banana', 'b')) # Output: 0 18 | print(find_char('hello', 'l')) # Output: 2 19 | print(find_char('code', 'a')) # Output: -1 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/133_count_char.py: -------------------------------------------------------------------------------- 1 | # Title: count_char 2 | 3 | """ 4 | Write a function that counts the occurrences of a specified character in a given string. 5 | 6 | count_char('hello', 'l') -> 2 7 | 8 | count_char('code', 'd') -> 1 9 | 10 | count_char('banana', 'a') -> 3 11 | """ 12 | 13 | def count_char(s: str, char_to_count: str) -> int: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(count_char('hello', 'l')) # Output: 2 18 | print(count_char('code', 'd')) # Output: 1 19 | print(count_char('banana', 'a')) # Output: 3 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/136_swap_case.py: -------------------------------------------------------------------------------- 1 | # Title: swap_case 2 | 3 | """ 4 | Write a function that returns a new string with the case of each character in the given string swapped. 5 | 6 | swap_case('hello') -> 'HELLO' 7 | 8 | swap_case('CODE') -> 'code' 9 | 10 | swap_case('aPpLe') -> 'ApPlE' 11 | """ 12 | 13 | def swap_case(s: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(swap_case('hello')) # Output: 'HELLO' 18 | print(swap_case('CODE')) # Output: 'code' 19 | print(swap_case('aPpLe')) # Output: 'ApPlE' 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/138_split_string.py: -------------------------------------------------------------------------------- 1 | # Title: split_string 2 | 3 | """ 4 | Write a function that splits a given string into a list of words using a specified delimiter. 5 | 6 | split_string('apple,banana,orange', ',') -> ['apple', 'banana', 'orange'] 7 | 8 | split_string('red.green.blue', '.') -> ['red', 'green', 'blue'] 9 | 10 | split_string('python/java/html', '/') -> ['python', 'java', 'html'] 11 | """ 12 | 13 | def split_string(s: str, delimiter: str) -> list: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(split_string('apple,banana,orange', ',')) # Output: ['apple', 'banana', 'orange'] 18 | print(split_string('red.green.blue', '.')) # Output: ['red', 'green', 'blue'] 19 | print(split_string('python/java/html', '/')) # Output: ['python', 'java', 'html'] 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/140_reverse_string.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_string 2 | 3 | """ 4 | Write a function that takes a string as input and returns the string reversed. 5 | 6 | reverse_string('hello') -> 'olleh' 7 | 8 | reverse_string('code') -> 'edoc' 9 | 10 | reverse_string('banana') -> 'ananab' 11 | """ 12 | 13 | def reverse_string(s: str) -> str: 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(reverse_string('hello')) # Output: 'olleh' 18 | print(reverse_string('code')) # Output: 'edoc' 19 | print(reverse_string('banana')) # Output: 'ananab' 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/281_count_lower_letters.py: -------------------------------------------------------------------------------- 1 | # Title: count_lower_letters 2 | 3 | """ 4 | Write a function that counts the number of lowercase letters present in a given string 's'. 5 | 6 | count_lower_letters("Hello World") → 8 7 | count_lower_letters("LOWERCASE") → 0 8 | count_lower_letters("MixedCase123") → 5 9 | """ 10 | 11 | def count_lower_letters(s: str) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(count_lower_letters('Hello')) # Output: 4 16 | print(count_lower_letters('LOWERCASE')) # Output: 0 17 | print(count_lower_letters('MixedCase1')) # Output: 7 18 | print(count_lower_letters('NoLower?')) # Output: 5 19 | print(count_lower_letters('uppercase')) # Output: 9 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/282_extract_uppercase.py: -------------------------------------------------------------------------------- 1 | # Title: extract_uppercase 2 | 3 | """ 4 | Write a function that extracts all the uppercase letters from the given string 's' and return them as a new string in the order they appear. 5 | 6 | extract_uppercase("Hello World") → "HW" 7 | extract_uppercase("nouppercasehere") → "" 8 | extract_uppercase("CODINGDORS") → "CODINGDORS" 9 | """ 10 | 11 | def extract_uppercase(s: str) -> str: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(extract_uppercase('Hello World')) # Output: 'HW' 16 | print(extract_uppercase('noupper')) # Output: '' 17 | print(extract_uppercase('CODING')) # Output: 'CODING' 18 | print(extract_uppercase('abcDEF')) # Output: 'DEF' 19 | print(extract_uppercase('AbCdEf')) # Output: 'ACE' 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/285_reverse_swap.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_swap 2 | 3 | """ 4 | Write a function that returns a new string that is the reverse of the given string 's', and where the case of each letter in the original string is swapped (i.e., lowercase letters become uppercase and uppercase letters become lowercase). 5 | 6 | reverse_swap("Hello") → "OLLEh" 7 | reverse_swap("wOrLd123!") → "!321DlRoW" 8 | reverse_swap("sWAP mE") → "eM pawS" 9 | """ 10 | 11 | def reverse_swap(s: str) -> str: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(reverse_swap('Hello')) # Output: 'OLLEh' 16 | print(reverse_swap('wOrLd123!')) # Output: '!321DlRoW' 17 | print(reverse_swap('sWAP mE')) # Output: 'eM pawS' 18 | print(reverse_swap('eM pawS')) # Output: 'sWAP mE' 19 | print(reverse_swap('aBcD')) # Output: 'dCbA' 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/286_replace_upper.py: -------------------------------------------------------------------------------- 1 | # Title: replace_upper 2 | 3 | """ 4 | Write a function that returns a new string where every uppercase letter from the given string 's' is replaced with an underscore (_). 5 | 6 | replace_upper("helloWorld") → "hello_orld" 7 | replace_upper("replaceUppeR") → "replace_ppe_" 8 | replace_upper("cOdInG") → "c_d_n_" 9 | """ 10 | 11 | def replace_upper(s: str) -> str: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(replace_upper('hiWorld')) # Output: 'hi_orld' 16 | print(replace_upper('replAce')) # Output: 'repl_ce' 17 | print(replace_upper('cOdInG')) # Output: 'c_d_n_' 18 | print(replace_upper('lower')) # Output: 'lower' 19 | print(replace_upper('hi123')) # Output: 'hi123' 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/291_triple_char.py: -------------------------------------------------------------------------------- 1 | # Title: triple_char 2 | 3 | """ 4 | Given a string 's', return a new string where for every char in the original, there are three chars. 5 | 6 | triple_char('The') → 'TTThhheee' 7 | triple_char('Abc') → 'AAAbbbccc' 8 | triple_char('code') → 'cccooodddeee' 9 | """ 10 | 11 | def triple_char(s: str) -> str: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(triple_char('The')) # Output: 'TTThhheee' 16 | print(triple_char('Abc')) # Output: 'AAAbbbccc' 17 | print(triple_char('code')) # Output: 'cccooodddeee' 18 | print(triple_char('aa')) # Output: 'aaaaaa' 19 | print(triple_char('z')) # Output: 'zzz' 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/292_hi_ho.py: -------------------------------------------------------------------------------- 1 | # Title: hi_ho 2 | 3 | """ 4 | Return True if the string "hi" and "ho" appear the same number of times in the given string. 5 | 6 | hi_ho('hiho') → True 7 | hi_ho('hihi') → False 8 | hi_ho('1hi1hohello') → True 9 | """ 10 | 11 | def hi_ho(s: str) -> bool: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(hi_ho('hiho')) # Output: True 16 | print(hi_ho('hihi')) # Output: False 17 | print(hi_ho('1hi1hohello')) # Output: True 18 | print(hi_ho('hi1hohihoa')) # Output: True 19 | print(hi_ho('hithere')) # Output: False 20 | -------------------------------------------------------------------------------- /CodingDors/7_loops_in_strings/293_count_code_times.py: -------------------------------------------------------------------------------- 1 | # Title: count_code_times 2 | 3 | """ 4 | Return the number of times that the string "code" appears anywhere in the given string. 5 | 6 | count_code_times('aaacodebbb') → 1 7 | count_code_times('codexxcode') → 2 8 | count_code_times('cozexxcope') → 0 9 | """ 10 | 11 | def count_code_times(s: str) -> int: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(count_code_times('aaacodebbb')) # Output: 1 16 | print(count_code_times('codexxcode')) # Output: 2 17 | print(count_code_times('cozexxcope')) # Output: 0 18 | print(count_code_times('coding')) # Output: 0 19 | print(count_code_times('codicode')) # Output: 1 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/308_count_odds_list.py: -------------------------------------------------------------------------------- 1 | # Title: count_odds_list 2 | 3 | """ 4 | Return the number of odd integers in the given list. Note: the % "mod" operator computes the remainder, e.g. 5 % 2 is 1. 5 | 6 | 7 | count_odds_list([2, 1, 2, 3, 4]) → 2 8 | count_odds_list([2, 2, 5]) → 1 9 | count_odds_list([1, 3, 5]) → 3 10 | """ 11 | 12 | def count_odds_list(l: list) -> int: 13 | return 14 | 15 | # Test your code (copy and past this block of code to test your solution) 16 | print(count_odds_list([2, 1, 2, 3, 4])) # Output: 2 17 | print(count_odds_list([2, 2, 5])) # Output: 1 18 | print(count_odds_list([1, 3, 5])) # Output: 3 19 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/309_has33_list.py: -------------------------------------------------------------------------------- 1 | # Title: has33_list 2 | 3 | """ 4 | Given a list of integers, return True if the list contains a 3 next to a 3 somewhere. 5 | 6 | has33_list([1, 3, 3]) → True 7 | has33_list([1, 3, 1, 3]) → False 8 | has33_list([3, 1, 3]) → False 9 | """ 10 | 11 | def has33_list(l: list) -> bool: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(has33_list([1, 3, 3])) # Output: True 16 | print(has33_list([1, 3, 1, 3])) # Output: False 17 | print(has33_list([3, 1, 3])) # Output: False 18 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/310_list456.py: -------------------------------------------------------------------------------- 1 | # Title: list456 2 | 3 | """ 4 | Given a list of integers, return True if the sequence of numbers 4, 5, 6 appears in the list somewhere. 5 | 6 | list456([1, 4, 5, 6, 1]) → True 7 | list456([1, 4, 5, 4, 6]) → False 8 | list456([1, 1, 2, 4, 5, 6]) → True 9 | """ 10 | 11 | def list456(l: list) -> bool: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(list456([1, 4, 5, 6, 1])) # Output: True 16 | print(list456([1, 4, 5, 4, 6])) # Output: False 17 | print(list456([1, 1, 2, 4, 5, 6])) # Output: True 18 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/311_sum_matrix_elements.py: -------------------------------------------------------------------------------- 1 | # Title: sum_matrix_elements 2 | 3 | """ 4 | Given a 2-dimensional list (matrix) of integers, write a Python function that calculates and returns the sum of all its elements using loops. 5 | 6 | sum_matrix_elements([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) -> 45 7 | sum_matrix_elements([[10]]) -> 10 8 | """ 9 | 10 | def sum_matrix_elements(matrix): 11 | return 12 | 13 | # Test your code (copy and past this block of code to test your solution) 14 | print(sum_matrix_elements([[1, 2, 3], [4, 5, 6], [7, 8, 9]])) # Output: 45 15 | print(sum_matrix_elements([[10]])) # Output: 10 16 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/312_has_letter_a_matrix.py: -------------------------------------------------------------------------------- 1 | # Title: has_letter_a_matrix 2 | 3 | """ 4 | Given a 2-dimensional list (matrix) where each element is a single letter, write a Python function that determines if the letter 'a' exists in the matrix. If the letter 'a' is found, the function should return True, otherwise, it should return False. 5 | 6 | has_letter_a_matrix([['b', 'c', 'd'], ['e', 'f', 'g'], ['h', 'i', 'a']]) -> True 7 | has_letter_a_matrix([['b', 'c', 'd'], ['e', 'f', 'g'], ['h', 'i', 'j']]) -> False 8 | """ 9 | 10 | def has_letter_a_matrix(matrix): 11 | return 12 | 13 | # Test your code (copy and past this block of code to test your solution) 14 | print(has_letter_a_matrix([['b', 'c', 'd'], ['e', 'f', 'g'], ['h', 'i', 'a']])) # Output: True 15 | print(has_letter_a_matrix([['b', 'c', 'd'], ['e', 'f', 'g'], ['h', 'i', 'j']])) # Output: False 16 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/313_sort_list.py: -------------------------------------------------------------------------------- 1 | # Title: sort_list 2 | 3 | """ 4 | Given a list of integers, return a the same list sorted in ascending order. 5 | 6 | sort_list([25, 12, 22, 11]) -> [11, 12, 22, 25] 7 | sort_list([-5, 0, -2, 3, 2, 1]) -> [-5, -2, 0, 1, 2, 3] 8 | """ 9 | 10 | def sort_list(l: list) -> list: 11 | return 12 | 13 | # Test your code (copy and past this block of code to test your solution) 14 | print(sort_list([25, 12, 22, 11])) # Output: [11, 12, 22, 25] 15 | print(sort_list([-5, 0, -2, 3, 2, 1])) # Output: [-5, -2, 0, 1, 2, 3] 16 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/81_print_to_n_for_loop.py: -------------------------------------------------------------------------------- 1 | # Title: print_to_n_for_loop 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all numbers from 0 to n inclusive, using a for loop. 5 | 6 | print_to_n_for_loop(5) -> [0, 1, 2, 3, 4, 5] 7 | 8 | print_to_n_for_loop(3) -> [0, 1, 2, 3] 9 | 10 | print_to_n_for_loop(1) -> [0, 1] 11 | """ 12 | 13 | def print_to_n_for_loop(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(print_to_n_for_loop(5)) # Output: [0, 1, 2, 3, 4, 5] 18 | print(print_to_n_for_loop(3)) # Output: [0, 1, 2, 3] 19 | print(print_to_n_for_loop(1)) # Output: [0, 1] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/82_print_to_n_even.py: -------------------------------------------------------------------------------- 1 | # Title: print_to_n_even 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all even integers from 0 to n inclusive, using a for loop. 5 | 6 | print_to_n_even(5) -> [0, 2, 4] 7 | 8 | print_to_n_even(10) -> [0, 2, 4, 6, 8, 10] 9 | 10 | print_to_n_even(1) -> [0] 11 | """ 12 | 13 | def print_to_n_even(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(print_to_n_even(5)) # Output: [0, 2, 4] 18 | print(print_to_n_even(10)) # Output: [0, 2, 4, 6, 8, 10] 19 | print(print_to_n_even(1)) # Output: [0] 20 | print(print_to_n_even(3)) # Output: [0, 2] 21 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/84_print_odd_to_n_forloop.py: -------------------------------------------------------------------------------- 1 | # Title: print_odd_to_n_forloop 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all odd integers from 0 to n inclusive, using a for loop. 5 | 6 | print_odd_to_n_forloop(5) -> [1, 3, 5] 7 | 8 | print_odd_to_n_forloop(10) -> [1, 3, 5, 7, 9] 9 | 10 | print_odd_to_n_forloop(1) -> [1] 11 | """ 12 | 13 | def print_odd_to_n_forloop(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(print_odd_to_n_forloop(5)) # Output: [1, 3, 5] 18 | print(print_odd_to_n_forloop(10)) # Output: [1, 3, 5, 7, 9] 19 | print(print_odd_to_n_forloop(1)) # Output: [1] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/85_print_one_to_n_while.py: -------------------------------------------------------------------------------- 1 | # Title: print_one_to_n_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all the integers from 1 to n, inclusive, using a while loop. 5 | 6 | print_one_to_n_while(5) -> [1, 2, 3, 4, 5] 7 | 8 | print_one_to_n_while(10) -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 9 | 10 | print_one_to_n_while(0) -> [] 11 | """ 12 | 13 | def print_one_to_n_while(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(print_one_to_n_while(5)) # Output: [1, 2, 3, 4, 5] 18 | print(print_one_to_n_while(10)) # Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 19 | print(print_one_to_n_while(1)) # Output: [1] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/86_print_even_number_while.py: -------------------------------------------------------------------------------- 1 | # Title: print_even_number_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all even integers from 0 to n inclusive, using a while loop. 5 | 6 | print_even_number_while(5) -> [0, 2, 4] 7 | 8 | print_even_number_while(10) -> [0, 2, 4, 6, 8, 10] 9 | 10 | print_even_number_while(1) -> [0] 11 | """ 12 | 13 | def print_even_number_while(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(print_even_number_while(5)) # Output: [0, 2, 4] 18 | print(print_even_number_while(10)) # Output: [0, 2, 4, 6, 8, 10] 19 | print(print_even_number_while(1)) # Output: [0] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/88_print_to_n_odd_while.py: -------------------------------------------------------------------------------- 1 | # Title: print_to_n_odd_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all odd integers from 0 to n inclusive, using a while loop. 5 | 6 | print_to_n_odd_while(5) -> [1, 3, 5] 7 | 8 | print_to_n_odd_while(10) -> [1, 3, 5, 7, 9] 9 | 10 | print_to_n_odd_while(1) -> [1] 11 | """ 12 | 13 | def print_to_n_odd_while(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(print_to_n_odd_while(5)) # Output: [1, 3, 5] 18 | print(print_to_n_odd_while(10)) # Output: [1, 3, 5, 7, 9] 19 | print(print_to_n_odd_while(1)) # Output: [1] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/89_reverse_n_for.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_n_for 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all numbers from n to 0 inclusive (reverse order), using a for loop. 5 | 6 | reverse_n_for(5) -> [5,4, 3, 2, 1, 0] 7 | 8 | reverse_n_for(3) -> [3, 2, 1, 0] 9 | 10 | reverse_n_for(1) -> [1, 0] 11 | """ 12 | 13 | def reverse_n_for(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(reverse_n_for(5)) # Output: [5, 4, 3, 2, 1, 0] 18 | print(reverse_n_for(3)) # Output: [3, 2, 1, 0] 19 | print(reverse_n_for(1)) # Output: [1, 0] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/90_reverse_n_while.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_n_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all numbers from n to 0 inclusive (reverse order), using a while loop. 5 | 6 | reverse_n_while(5) -> [5, 4, 3, 2, 1, 0] 7 | 8 | reverse_n_while(3) -> [3, 2, 1, 0] 9 | 10 | reverse_n_while(1) -> [1, 0] 11 | """ 12 | 13 | def reverse_n_while(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(reverse_n_while(5)) # Output: [5, 4, 3, 2, 1, 0] 18 | print(reverse_n_while(3)) # Output: [3, 2, 1, 0] 19 | print(reverse_n_while(1)) # Output: [1, 0] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/91_reverse_n_even_for.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_n_even_for 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all even numbers from n to 0 inclusive, using a for loop. 5 | 6 | reverse_n_even_for(5) -> [4, 2, 0] 7 | 8 | reverse_n_even_for(3) -> [2, 0] 9 | 10 | reverse_n_even_for(1) -> [0] 11 | """ 12 | 13 | def reverse_n_even_for(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(reverse_n_even_for(5)) # Output: [4, 2, 0] 18 | print(reverse_n_even_for(3)) # Output: [2, 0] 19 | print(reverse_n_even_for(1)) # Output: [0] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/92_reverse_n_even_while.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_n_even_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all even numbers from n to 0 inclusive, using a while loop. 5 | 6 | reverse_n_even_while(5) -> [4, 2, 0] 7 | 8 | reverse_n_even_while(3) -> [2, 0] 9 | 10 | reverse_n_even_while(1) -> [0] 11 | """ 12 | 13 | def reverse_n_even_while(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(reverse_n_even_while(5)) # Output: [4, 2, 0] 18 | print(reverse_n_even_while(3)) # Output: [2, 0] 19 | print(reverse_n_even_while(1)) # Output: [0] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/93_reverse_n_odd_while.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_n_odd_while 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all odd numbers from n to 1 inclusive, using a while loop. 5 | 6 | reverse_n_odd_while(5) -> [5, 3, 1] 7 | 8 | reverse_n_odd_while(3) -> [3, 1] 9 | 10 | reverse_n_odd_while(1) -> [1] 11 | """ 12 | 13 | def reverse_n_odd_while(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(reverse_n_odd_while(5)) # Output: [5, 3, 1] 18 | print(reverse_n_odd_while(3)) # Output: [3, 1] 19 | print(reverse_n_odd_while(1)) # Output: [1] 20 | -------------------------------------------------------------------------------- /CodingDors/8_loops_in_lists/94_reverse_n_odd_for.py: -------------------------------------------------------------------------------- 1 | # Title: reverse_n_odd_for 2 | 3 | """ 4 | Write a Python function that takes an integer n as input and returns a list that contains all odd numbers from n to 0, using a for loop. 5 | 6 | reverse_n_odd_for(5) -> [5, 3, 1] 7 | 8 | reverse_n_odd_for(3) -> [3, 1] 9 | 10 | reverse_n_odd_for(1) -> [1] 11 | """ 12 | 13 | def reverse_n_odd_for(n: int): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(reverse_n_odd_for(5)) # Output: [5, 3, 1] 18 | print(reverse_n_odd_for(3)) # Output: [3, 1] 19 | print(reverse_n_odd_for(1)) # Output: [1] 20 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/223_invert_dictionary.py: -------------------------------------------------------------------------------- 1 | # Title: invert_dictionary 2 | 3 | """ 4 | Given a dictionary, return a new dictionary with keys and values swapped. 5 | 6 | invert_dictionary({'a': 1, 'b': 2}) -> {1: 'a', 2: 'b'} 7 | invert_dictionary({'apple': 'fruit', 'carrot': 'vegetable'}) -> {'fruit': 'apple', 'vegetable': 'carrot'} 8 | invert_dictionary({}) -> {} 9 | """ 10 | 11 | def invert_dictionary(d): 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(invert_dictionary({'a': 1, 'b': 2})) # Output: {1: 'a', 2: 'b'} 16 | print(invert_dictionary({'apple': 'fruit', 'carrot': 'vegetable'})) # Output: {'fruit': 'apple', 'vegetable': 'carrot'} 17 | print(invert_dictionary({})) # Output: {} 18 | print(invert_dictionary({'key': 'value', 'another_key': 'value'})) # Output: {'value': 'another_key'} 19 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/228_keys_of_max_value.py: -------------------------------------------------------------------------------- 1 | # Title: keys_of_max_value 2 | 3 | """ 4 | Given a dictionary with integer values, return a list of keys with the maximum value. 5 | 6 | keys_of_max_value({'a': 1, 'b': 2, 'c': 1}) -> ['b'] 7 | keys_of_max_value({'apple': 3, 'banana': 5, 'cherry': 5}) -> ['banana', 'cherry'] 8 | """ 9 | 10 | def keys_of_max_value(d): 11 | return 12 | 13 | # Test your code (copy and past this block of code to test your solution) 14 | print(keys_of_max_value({'a': 1, 'b': 2, 'c': 1})) # Output: ['b'] 15 | print(keys_of_max_value({'apple': 3, 'banana': 5, 'cherry': 5})) # Output: ['banana', 'cherry'] 16 | print(keys_of_max_value({})) # Output: [] 17 | print(keys_of_max_value({'x': 10, 'y': 10, 'z': 10})) # Output: ['x', 'y', 'z'] 18 | print(keys_of_max_value({'key1': 100, 'key2': 50, 'key3': 25})) # Output: ['key1'] 19 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/229_common_keys.py: -------------------------------------------------------------------------------- 1 | # Title: common_keys 2 | 3 | """ 4 | Given two dictionaries, return True if at least one of the keys that are present in both dictionaries. 5 | 6 | common_keys({'a': 1}, {'a': 2}) -> True 7 | common_keys({'a': 1}, {'b': 2}) -> False 8 | common_keys({'a': 1, 'b': 2}, {'c': 3, 'b': 3}) -> True 9 | """ 10 | 11 | def common_keys(d1, d2): 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(common_keys({'a': 1}, {'a': 2})) # Output: True 16 | print(common_keys({'a': 1}, {'b': 2})) # Output: False 17 | print(common_keys({'a': 1, 'b': 2}, {'c': 3, 'b': 3})) # Output: True 18 | print(common_keys({'a': 1, 'b': 2}, {'c': 3, 'd': 3})) # Output: False 19 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/230_sum_values_dict.py: -------------------------------------------------------------------------------- 1 | # Title: sum_values_dict 2 | 3 | """ 4 | Given a dictionary with integer values, return the sum of all the values. 5 | 6 | sum_values_dict({'a': 1}) -> 1 7 | sum_values_dict({'a': 1, 'b': 7}) -> 8 8 | sum_values_dict({'a': 1, 'b': 7, 'c': 9}) -> 17 9 | """ 10 | 11 | def sum_values_dict(d): 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(sum_values_dict({'a': 1})) # Output: 1 16 | print(sum_values_dict({'a': 1, 'b': 7})) # Output: 8 17 | print(sum_values_dict({'a': 1, 'b': 7, 'c': 9})) # Output: 17 18 | print(sum_values_dict({'a': 1, 'b': 4, 'c': 7})) # Output: 12 19 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/231_sorted_keys.py: -------------------------------------------------------------------------------- 1 | # Title: sorted_keys 2 | 3 | """ 4 | Given a dictionary, return a list of its keys sorted in ascending order. 5 | 6 | sorted_keys({'c': 1, 'a': 2, 'b': 1}) -> ['a', 'b', 'c'] 7 | sorted_keys({'banana': 5, 'apple': 3, 'cherry': 7}) -> ['apple', 'banana', 'cherry'] 8 | """ 9 | 10 | def sorted_keys(d): 11 | return 12 | 13 | # Test your code (copy and past this block of code to test your solution) 14 | print(sorted_keys({'c': 1, 'a': 2, 'b': 1})) # Output: ['a', 'b', 'c'] 15 | print(sorted_keys({'banana': 5, 'apple': 3, 'cherry': 7})) # Output: ['apple', 'banana', 'cherry'] 16 | print(sorted_keys({})) # Output: [] 17 | print(sorted_keys({'z': 10, 'x': 15, 'y': 20})) # Output: ['x', 'y', 'z'] 18 | print(sorted_keys({'2': 'b', '1': 'a', '3': 'c'})) # Output: ['1', '2', '3'] 19 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/233_dictionary_size.py: -------------------------------------------------------------------------------- 1 | # Title: dictionary_size 2 | 3 | """ 4 | Given a dictionary, return the number of key-value pairs it contains. 5 | 6 | dictionary_size({}) -> 0 7 | dictionary_size({'name': 'Gi'}) -> 1 8 | dictionary_size({'a':1, 'b':4, 'c': 7}) -> 3 9 | """ 10 | 11 | def dictionary_size(d): 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(dictionary_size({})) # Output: 0 16 | print(dictionary_size({'name': 'Gi'})) # Output: 1 17 | print(dictionary_size({'a': 1, 'b': 4, 'c': 7})) # Output: 3 18 | print(dictionary_size({'apple': 0.5, 'banana': 0.25, 'cherry': 0.75})) # Output: 3 19 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/235_square_values.py: -------------------------------------------------------------------------------- 1 | # Title: square_values 2 | 3 | """ 4 | Given a dictionary with integer values, return a new dictionary with the values squared. 5 | 6 | square_values({'a':1}) -> {'a': 1} 7 | square_values({'a':1, 'b': 5}) -> {'a': 1, 'b': 25} 8 | square_values({'a':1, 'b': 5, 'c': 9}) -> {'a': 1, 'b': 25, 'c': 9} 9 | """ 10 | 11 | def square_values(d): 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(square_values({'a': 1})) # Output: {'a': 1} 16 | print(square_values({'a': 1, 'b': 7})) # Output: {'a': 1, 'b': 49} 17 | print(square_values({'a': 1, 'b': 7, 'c': 9})) # Output: {'a': 1, 'b': 49, 'c': 81} 18 | print(square_values({'a': 1, 'b': 4, 'c': 7})) # Output: {'a': 1, 'b': 16, 'c': 49} 19 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/236_update_value.py: -------------------------------------------------------------------------------- 1 | # Title: update_value 2 | 3 | """ 4 | Given a dictionary, a key, and a value, update the value associated with the key in the dictionary. If the key does not exist, add the key-value pair to the dictionary. 5 | 6 | update_value({}, 'name', 'Gi') -> {'name': 'Gi'} 7 | update_value({'name': 'Gi'}, 'name', 'Leo') -> {'name': 'Leo'} 8 | update_value({'name': 'Gi'}, 'age', 25) -> {'name': 'Gi', 'age': 25} 9 | """ 10 | 11 | def update_value(d, key, value): 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(update_value({}, 'name', 'Gi')) # Output: {'name': 'Gi'} 16 | print(update_value({'name': 'Gi'}, 'name', 'Leo')) # Output: {'name': 'Leo'} 17 | print(update_value({'name': 'Gi'}, 'age', 25)) # Output: {'name': 'Gi', 'age': 25} 18 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/30_find_person.py: -------------------------------------------------------------------------------- 1 | # Title: find_person 2 | 3 | """ 4 | Given a dictionary 'd' and a string 'name', return True if the given name exist in our dictionary. Otherwise, False. 5 | 6 | find_person({'Gi': 123, 'Leo': 456}, 'Gi') -> True 7 | 8 | find_person({'Gi': 123, 'Leo': 456}, 'Ana') -> False 9 | """ 10 | 11 | def find_person(d: dict,name: str) -> bool: 12 | return 13 | 14 | # Test your code (copy and past this block of code to test your solution) 15 | print(find_person({'Gi': 123, 'Leo': 456}, 'Gi')) # Output: True 16 | print(find_person({'Gi': 123, 'Leo': 456}, 'Ana')) # Output: False 17 | print(find_person({}, 'name')) # Output: False 18 | print(find_person({'name': 'John'}, 'Name')) # Output: False 19 | print(find_person({'name': 'John'}, 'name')) # Output: True 20 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/314_create_dictionary.py: -------------------------------------------------------------------------------- 1 | # Title: create_dictionary 2 | 3 | """ 4 | Given a string 'name' and an integer 'age', return a dictionary with the pair of key 'name' and value 'age' added. 5 | 6 | Hint: Dictionaries are used to store data values in key:value pairs. 7 | 8 | create_dictionary(gi', 25) -> {'gi': 25} 9 | create_dictionary('leo', 41) -> {'leo': 41} 10 | create_dictionary('rod', 12) -> {'rod': 12} 11 | """ 12 | 13 | def create_dictionary(name, age): 14 | return 15 | 16 | # Test your code (copy and past this block of code to test your solution) 17 | print(create_dictionary('gi', 25)) # Output: {'gi': 25} 18 | print(create_dictionary('leo', 41)) # Output: {'leo': 41} 19 | print(create_dictionary('rod', 12)) # Output: {'rod': 12} 20 | -------------------------------------------------------------------------------- /CodingDors/9_dictionaries/316_return_value.py: -------------------------------------------------------------------------------- 1 | # Title: return_value 2 | 3 | """ 4 | We have a dictionary 'd' that contains as key the fruit and the value its price. Given a string 'fruit', return the price of this fruit in the dictionary. 5 | 6 | return_value({'apple': 0.5, 'banana': 0.25, 'cherry': 0.75}, 'apple') -> 0.5 7 | return_value({'apple': 0.5, 'banana': 0.25, 'cherry': 0.75}, 'cherry') -> 0.75 8 | """ 9 | 10 | def return_value(d, fruit): 11 | return 12 | 13 | # Test your code (copy and past this block of code to test your solution) 14 | print(return_value({'apple': 0.5, 'banana': 0.25, 'cherry': 0.75}, 'apple')) # Output: 0.5 15 | print(return_value({'apple': 0.5, 'banana': 0.25, 'cherry': 0.75}, 'banana')) # Output: 0.25 16 | print(return_value({'apple': 0.5, 'banana': 0.25, 'cherry': 0.75}, 'cherry')) # Output: 0.75 17 | -------------------------------------------------------------------------------- /Labs/lab1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | // TODO: Prompt for start size 8 | int start_size; 9 | do 10 | { 11 | start_size = get_int("Start size: \n"); 12 | } 13 | while (start_size < 9); 14 | 15 | // TODO: Prompt for end size 16 | int end_size; 17 | do 18 | { 19 | end_size = get_int("End size: \n"); 20 | } 21 | while (end_size < start_size); 22 | 23 | // TODO: Calculate number of years until we reach threshold 24 | int current_size = start_size; 25 | int years_passed = 0; 26 | while (current_size < end_size) 27 | { 28 | current_size = round(current_size + current_size/3 - current_size/4); 29 | years_passed++; 30 | } 31 | printf("Years: %i \n", years_passed); 32 | } 33 | -------------------------------------------------------------------------------- /Labs/lab3.txt: -------------------------------------------------------------------------------- 1 | Explanation available at: https://www.youtube.com/watch?v=lUs-iU3PWcU 2 | 3 | sort1 uses: bubblesort 4 | 5 | How do you know?: because on already sorted data it performed 6 | way faster than selection sort 7 | 8 | sort2 uses: MergeSort 9 | 10 | How do you know?: Because on reversed values it was the fastest algorithm 11 | 12 | sort3 uses: selection sort 13 | 14 | How do you know?: because for sorted data it had about the same time as for 15 | reversed or unsorted data 16 | 17 | -------------------------------------------------------------------------------- /Labs/lab4/smiley/helpers.c: -------------------------------------------------------------------------------- 1 | #include "helpers.h" 2 | 3 | void colorize(int height, int width, RGBTRIPLE image[height][width]) 4 | { 5 | // Change all black pixels to a color of your choosing 6 | for(int w = 0; w < width; w++){ 7 | for(int h = 0; h < height; h++){ 8 | if(image[h][w].rgbtBlue == 0 && image[h][w].rgbtGreen == 0 && image[h][w].rgbtRed == 0){ 9 | image[h][w].rgbtBlue = 127; 10 | image[h][w].rgbtGreen = 0; 11 | image[h][w].rgbtRed = 255; 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Labs/lab7/1.sql: -------------------------------------------------------------------------------- 1 | SELECT name from songs; 2 | -------------------------------------------------------------------------------- /Labs/lab7/2.sql: -------------------------------------------------------------------------------- 1 | SELECT name FROM songs ORDER BY(tempo); 2 | -------------------------------------------------------------------------------- /Labs/lab7/3.sql: -------------------------------------------------------------------------------- 1 | SELECT name FROM songs ORDER BY(duration_ms) DESC LIMIT 5; 2 | -------------------------------------------------------------------------------- /Labs/lab7/4.sql: -------------------------------------------------------------------------------- 1 | SELECT name FROM songs WHERE danceability > 0.75 AND energy > 0.75 and valence > 0.75; 2 | -------------------------------------------------------------------------------- /Labs/lab7/5.sql: -------------------------------------------------------------------------------- 1 | SELECT AVG(energy) FROM songs; 2 | -------------------------------------------------------------------------------- /Labs/lab7/6.sql: -------------------------------------------------------------------------------- 1 | SELECT name FROM songs 2 | WHERE artist_id = (SELECT id FROM artists WHERE name="Post Malone"); 3 | -------------------------------------------------------------------------------- /Labs/lab7/7.sql: -------------------------------------------------------------------------------- 1 | SELECT AVG(energy) FROM songs 2 | WHERE artist_id = (SELECT id FROM artists WHERE name="Drake"); 3 | -------------------------------------------------------------------------------- /Labs/lab7/8.sql: -------------------------------------------------------------------------------- 1 | SELECT name FROM songs WHERE name LIKE "%feat.%"; 2 | -------------------------------------------------------------------------------- /Practice Problems/Week1/WEEK 1 PRACTICE PROBLEMS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/Practice Problems/Week1/WEEK 1 PRACTICE PROBLEMS.pdf -------------------------------------------------------------------------------- /Practice Problems/Week1/debug/debug.c: -------------------------------------------------------------------------------- 1 | // Become familiar wih C syntax 2 | // Learn to debug buggy code 3 | 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | // Ask for your name and where live 10 | string name = get_string("What is your name? "); 11 | string location = get_string("Where do you live? "); 12 | 13 | // Say hello 14 | printf("Hello, %s, from %s!", name, location); 15 | } 16 | -------------------------------------------------------------------------------- /Practice Problems/Week2/WEEK 2 PRACTICE PROBLEMS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/Practice Problems/Week2/WEEK 2 PRACTICE PROBLEMS.pdf -------------------------------------------------------------------------------- /Practice Problems/Week3/max/max.c: -------------------------------------------------------------------------------- 1 | // Practice writing a function to find a max value 2 | 3 | #include 4 | #include 5 | 6 | int max(int array[], int n); 7 | 8 | int main(void) 9 | { 10 | int n; 11 | do 12 | { 13 | n = get_int("Number of elements: "); 14 | } 15 | while (n < 1); 16 | 17 | int arr[n]; 18 | 19 | for (int i = 0; i < n; i++) 20 | { 21 | arr[i] = get_int("Element %i: ", i); 22 | } 23 | 24 | printf("The max value is %i.\n", max(arr, n)); 25 | } 26 | 27 | // TODO: return the max value 28 | int max(int array[], int n) 29 | { 30 | int max_value = array[0]; 31 | 32 | for(int i = 0; i < n; i++){ 33 | if(max_value < array[i]){ 34 | max_value = array[i]; 35 | } 36 | } 37 | 38 | return max_value; 39 | } 40 | -------------------------------------------------------------------------------- /Practice Problems/Week6/bank/bank.py: -------------------------------------------------------------------------------- 1 | greeting = input("Greeting: ").strip().lower() 2 | 3 | if greeting.startswith("hello"): 4 | print("$0") 5 | elif greeting.startswith("h"): 6 | print("$20") 7 | else: 8 | print("$100") 9 | -------------------------------------------------------------------------------- /Practice Problems/Week6/figlet/figlet.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import random 3 | from pyfiglet import Figlet 4 | 5 | fontIsRandom = False 6 | 7 | if(len(sys.argv) == 1): 8 | fontIsRandom = True 9 | elif (len(sys.argv) == 3): 10 | fontIsRandom = False 11 | else: 12 | sys.exit("Command-line argument not expected") 13 | 14 | figlet = Figlet() 15 | 16 | availableFonts = figlet.getFonts() 17 | 18 | if fontIsRandom == False: 19 | if(sys.argv[1] not in ["-f", "--font"]): 20 | sys.exit("Second command-line argument incorrect") 21 | try: 22 | font = figlet.setFont(font=sys.argv[2]) 23 | except: 24 | sys.exit("Font Doesn't Exist") 25 | else: 26 | font = random.choice(availableFonts) 27 | 28 | txt = input("Input: ") 29 | 30 | print(figlet.renderText(txt)) 31 | -------------------------------------------------------------------------------- /Practice Problems/Week6/taqueria/taqueria.py: -------------------------------------------------------------------------------- 1 | menu = { 2 | "Baja Taco": 4.00, 3 | "Burrito": 7.50, 4 | "Bowl": 8.50, 5 | "Nachos": 11.00, 6 | "Quesadilla": 8.50, 7 | "Super Burrito": 8.50, 8 | "Super Quesadilla": 9.50, 9 | "Taco": 3.00, 10 | "Tortilla Salad": 8.00 11 | } 12 | 13 | total = 0 14 | 15 | while True: 16 | try: 17 | item = input("Item: ").title() 18 | if item in menu: 19 | total += menu[item] 20 | print(f"Total: $", end="") 21 | print("{:.2f}".format(total)) 22 | except EOFError: 23 | print() 24 | break 25 | -------------------------------------------------------------------------------- /Practice Problems/Week7/prophecy/schema.sql: -------------------------------------------------------------------------------- 1 | -- Create table 2 | CREATE TABLE new_students ( 3 | id INTEGER, 4 | student_name TEXT, 5 | PRIMARY KEY(id) 6 | ); 7 | 8 | CREATE TABLE houses ( 9 | id INTEGER, 10 | house TEXT, 11 | head TEXT, 12 | PRIMARY KEY(id) 13 | ); 14 | 15 | CREATE TABLE house_assignments ( 16 | id INTEGER, 17 | student_name INT, 18 | house INT, 19 | PRIMARY KEY(id) 20 | ); 21 | -------------------------------------------------------------------------------- /Practice Problems/Week9/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | 3 | app = Flask(__name__) 4 | app.run(debug=True) 5 | 6 | @app.route("/", methods=["GET", "POST"]) 7 | def index(): 8 | if request.method == "GET": 9 | return render_template("index.html") 10 | else: 11 | print("Form submitted!") 12 | color_selected = request.form.get("color") 13 | return render_template("color.html", color=color_selected) 14 | -------------------------------------------------------------------------------- /Practice Problems/Week9/templates/color.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block body %} 4 |

Your favorite color is {{ color }}.

5 | {% endblock %} 6 | -------------------------------------------------------------------------------- /Practice Problems/Week9/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block body %} 4 |
5 | What is your favorite color? 6 | 10 | 11 |
12 | {% endblock %} 13 | -------------------------------------------------------------------------------- /Practice Problems/Week9/templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block body %} 4 |
5 | What is your favorite color? 6 | 10 | 11 |
12 | {% endblock %} 13 | -------------------------------------------------------------------------------- /Problem Sets/FinalProject/project.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/Problem Sets/FinalProject/project.db -------------------------------------------------------------------------------- /Problem Sets/FinalProject/templates/apology.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Apology 5 | {% endblock %} 6 | 7 | {% block main %} 8 | 9 | 10 | {{ top }} 11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /Problem Sets/FinalProject/templates/email.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Sent 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 |
10 |
sender: {{emailDetail.sender}}
11 |
recipient: {{emailDetail.recipient}}
12 |
subject: {{emailDetail.subject}}
13 |
body: {{emailDetail.body}}
14 |
timestamp: {{emailDetail.timestamp}}
15 |
16 | 17 | 18 |
19 |
20 |
21 | {% endblock %} 22 | -------------------------------------------------------------------------------- /Problem Sets/FinalProject/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Sent 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 | {% for email in emails %} 10 |
11 |
sender: {{email.sender}}
12 |
recipient: {{email.recipient}}
13 |
subject: {{email.subject}}
14 |
body: {{email.body}}
15 |
timestamp: {{email.timestamp}}
16 |
17 | 18 | 19 |
20 |
21 | {% endfor %} 22 |
23 | {% endblock %} 24 | -------------------------------------------------------------------------------- /Problem Sets/FinalProject/templates/login.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Log In 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 |
10 | 11 |
12 |
13 | 14 |
15 | 16 |
17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /Problem Sets/FinalProject/templates/register.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Register 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 |
10 | 11 |
12 |
13 | 14 |
15 |
16 | 17 |
18 | 19 |
20 | {% endblock %} 21 | -------------------------------------------------------------------------------- /Problem Sets/FinalProject/templates/sent.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Sent 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 | {% for email in emails %} 10 |
11 |
sender: {{email.sender}}
12 |
recipient: {{email.recipient}}
13 |
subject: {{email.subject}}
14 |
body: {{email.body}}
15 |
timestamp: {{email.timestamp}}
16 |
17 | 18 | 19 |
20 |
21 | {% endfor %} 22 |
23 | {% endblock %} 24 | -------------------------------------------------------------------------------- /Problem Sets/pset1/cash1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int cents_owed; 8 | 9 | do 10 | { 11 | float dollars_owed = get_float("Change owed: "); 12 | cents_owed = round(dollars_owed * 100); 13 | } 14 | while (cents_owed <= 0); 15 | 16 | int quarters = cents_owed / 25; 17 | int dimes = (cents_owed % 25) / 10; 18 | int nickels = ((cents_owed % 25) % 10) / 5; 19 | int pennies = ((cents_owed % 25) % 10) % 5; 20 | 21 | printf("%d\n", quarters + dimes + nickels + pennies); 22 | } -------------------------------------------------------------------------------- /Problem Sets/pset1/cash2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | int main(void) 7 | { 8 | float change; 9 | 10 | do 11 | { 12 | change = round(get_float("Input your change: ") * 100); 13 | 14 | } 15 | while (change < 0); 16 | 17 | int count = 0; 18 | 19 | while (change >= 25) 20 | { 21 | count++; 22 | change = change - 25; 23 | } 24 | 25 | while (change >= 10) 26 | { 27 | count++; 28 | change = change - 10; 29 | } 30 | 31 | while (change >= 5) 32 | { 33 | count++; 34 | change = change - 5; 35 | } 36 | 37 | while (change >= 1) 38 | { 39 | count++; 40 | change = change - 1; 41 | } 42 | 43 | printf("%i\n", count); 44 | } -------------------------------------------------------------------------------- /Problem Sets/pset1/mario-less.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | int height; 7 | do{ 8 | height = get_int("Height: "); 9 | } 10 | while (height <= 0 || height > 8); 11 | 12 | for(int i = 0; i < height; i++){ 13 | for(int j = 0; j < height; j++){ 14 | if(i + j < height - 1){ 15 | printf(" "); 16 | } 17 | else{ 18 | printf("#"); 19 | } 20 | } 21 | printf("\n"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Problem Sets/pset1/mario-more.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | int height; 7 | do{ 8 | height = get_int("Height: "); 9 | } 10 | while (height <= 0 || height > 8); 11 | 12 | for(int i = 0; i < height; i++){ 13 | for(int j = 0; j < height; j++){ 14 | if(i + j < height - 1){ 15 | printf(" "); 16 | } 17 | else{ 18 | printf("#"); 19 | } 20 | } 21 | printf(" "); 22 | for(int k = 0; k < i+1; k++){ 23 | printf("#"); 24 | } 25 | printf("\n"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Problem Sets/pset6/hello.py: -------------------------------------------------------------------------------- 1 | from cs50 import get_string 2 | 3 | name = get_string("What is your name?\n") 4 | 5 | print(f"hello, {name}") -------------------------------------------------------------------------------- /Problem Sets/pset6/mario.py: -------------------------------------------------------------------------------- 1 | from cs50 import get_int 2 | 3 | def main(): 4 | while True: 5 | height = get_int("Height: ") 6 | if height >= 0 and height <= 8: 7 | break 8 | 9 | for num_hashes in range(1, height + 1): 10 | 11 | num_spaces = height - num_hashes 12 | 13 | print(" " * num_spaces, end="") 14 | print("#" * num_hashes, end="") 15 | 16 | print(" ", end="") 17 | 18 | print("#" * num_hashes) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() -------------------------------------------------------------------------------- /Problem Sets/pset7/fiftyville/answers.txt: -------------------------------------------------------------------------------- 1 | The THIEF is: Ernest 2 | The thief ESCAPED TO: London 3 | The ACCOMPLICE is: Berthold 4 | -------------------------------------------------------------------------------- /Problem Sets/pset7/fiftyville2022/answers.txt: -------------------------------------------------------------------------------- 1 | The THIEF is: Bruce 2 | The city the thief ESCAPED TO: New York City 3 | The ACCOMPLICE is: Robin 4 | -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/1.sql: -------------------------------------------------------------------------------- 1 | SELECT title FROM movies 2 | WHERE year = 2008; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/10.sql: -------------------------------------------------------------------------------- 1 | SELECT name from people 2 | JOIN directors ON people.id = directors.person_id 3 | JOIN movies ON directors.movie_id = movies.id 4 | JOIN ratings on movies.id = ratings.movie_id 5 | WHERE rating >= 9; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/11.sql: -------------------------------------------------------------------------------- 1 | SELECT movies.title from people 2 | JOIN stars ON people.id = stars.person_id 3 | JOIN movies ON stars.movie_id = movies.id 4 | JOIN ratings on movies.id = ratings.movie_id 5 | WHERE people.name = "Chadwick Boseman" 6 | ORDER BY rating DESC 7 | LIMIT 5; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/12.sql: -------------------------------------------------------------------------------- 1 | SELECT movies.title FROM people 2 | JOIN stars ON people.id = stars.person_id 3 | JOIN movies ON stars.movie_id = movies.id 4 | WHERE people.name = "Johnny Depp" AND movies.title IN( 5 | SELECT movies.title FROM people 6 | JOIN stars ON people.id = stars.person_id 7 | JOIN movies ON stars.movie_id = movies.id 8 | WHERE people.name = "Helena Bonham Carter"); -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/13.sql: -------------------------------------------------------------------------------- 1 | SELECT distinct(name) FROM people 2 | JOIN stars ON people.id = stars.person_id 3 | JOIN movies ON stars.movie_id = movies.id 4 | WHERE movies.title IN (SELECT distinct(movies.title) FROM people 5 | JOIN stars ON people.id = stars.person_id 6 | JOIN movies ON stars.movie_id = movies.id 7 | WHERE people.name = "Kevin Bacon" AND people.birth = 1958) AND people.name != "Kevin Bacon"; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/2.sql: -------------------------------------------------------------------------------- 1 | SELECT birth FROM people 2 | WHERE name = "Emma Stone"; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/3.sql: -------------------------------------------------------------------------------- 1 | SELECT title FROM movies 2 | WHERE year >= 2018 3 | ORDER BY 1 ASC; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/4.sql: -------------------------------------------------------------------------------- 1 | SELECT COUNT(title) FROM movies 2 | JOIN ratings on movies.id = ratings.movie_id 3 | WHERE rating = 10; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/5.sql: -------------------------------------------------------------------------------- 1 | SELECT title, year FROM movies 2 | WHERE title LIKE "Harry Potter%" 3 | ORDER BY 2; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/6.sql: -------------------------------------------------------------------------------- 1 | SELECT avg(rating) FROM ratings 2 | JOIN movies ON ratings.movie_id = movies.id 3 | WHERE year = 2012; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/7.sql: -------------------------------------------------------------------------------- 1 | SELECT movies.title, ratings.rating FROM movies 2 | JOIN ratings ON ratings.movie_id = movies.id 3 | WHERE year = 2010 4 | ORDER BY 2 DESC, 1; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/8.sql: -------------------------------------------------------------------------------- 1 | SELECT name from people 2 | JOIN stars ON people.id = stars.person_id 3 | JOIN movies ON stars.movie_id = movies.id 4 | WHERE movies.title = "Toy Story"; -------------------------------------------------------------------------------- /Problem Sets/pset7/movies/9.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT(people.name) from stars 2 | JOIN people ON stars.person_id = people.id 3 | JOIN movies ON stars.movie_id = movies.id 4 | WHERE movies.year = 2004 5 | ORDER BY birth; -------------------------------------------------------------------------------- /Problem Sets/pset8/lendas do cs50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/Problem Sets/pset8/lendas do cs50.png -------------------------------------------------------------------------------- /Problem Sets/pset8/styles.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | background-color: rgb(255, 255, 255); 4 | } 5 | .bluetext 6 | { 7 | text-align: center; 8 | color: rgb(44,153,181); 9 | } 10 | 11 | .pinktext 12 | { 13 | text-align: center; 14 | color: rgb(181, 44, 46); 15 | } 16 | .image 17 | { 18 | display: block; 19 | margin-left: auto; 20 | margin-right: auto; 21 | width:50%; 22 | } 23 | .blacktext 24 | { 25 | text-align: center; 26 | color: rgb(84, 84, 84); 27 | } 28 | .arrow 29 | { 30 | border: solid black; 31 | border-width: 0 3px 3px 0; 32 | display: inline-block; 33 | padding: 3px; 34 | } 35 | 36 | .right 37 | { 38 | transform: rotate(-45deg); 39 | -webkit-transform: rotate(-45deg); 40 | } 41 | 42 | .left 43 | { 44 | transform: rotate(135deg); 45 | -webkit-transform: rotate(135deg); 46 | } -------------------------------------------------------------------------------- /Problem Sets/pset9/templates/apology.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Apology 5 | {% endblock %} 6 | 7 | {% block main %} 8 | {{ top }} 9 | {% endblock %} 10 | -------------------------------------------------------------------------------- /Problem Sets/pset9/templates/buy.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Buy 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 |
10 | 11 |
12 |
13 | 14 |
15 | 16 |
17 | {% endblock %} -------------------------------------------------------------------------------- /Problem Sets/pset9/templates/login.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Log In 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 |
10 | 11 |
12 |
13 | 14 |
15 | 16 |
17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /Problem Sets/pset9/templates/quote.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Quote 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 |
10 | 11 |
12 | 13 |
14 | {% endblock %} -------------------------------------------------------------------------------- /Problem Sets/pset9/templates/quoted.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Quoted 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 |

A share of {{ stockSpec['name'] }} costs {{ stockSpec['price'] }}.

10 |
11 | {% endblock %} -------------------------------------------------------------------------------- /Problem Sets/pset9/templates/register.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %} 4 | Register 5 | {% endblock %} 6 | 7 | {% block main %} 8 |
9 |
10 | 11 |
12 |
13 | 14 |
15 |
16 | 17 |
18 | 19 |
20 | {% endblock %} 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Coding Resources 2 | 3 | In this repository you will find all the solutions for CS50, CS50 Python, CS50 Web, CS50 AI, The Odin Project and FreeCodeCamp. 4 | 5 | If you want to have full support from a programming expert, check this out: [https://www.dorscodingschool.com/products](https://codingdors.com/coachingplans) 6 | 7 | ––– DISCLAIMER ––– 8 | 9 | The following codes are for educational purposes only. Cheating or any other activities are highly discouraged! Using another person's code breaks the academic honesty guidelines. This solution is for those who have finished the problem sets and want to check for educational purposes, learning experience, and exploring alternative ways to approach problems and is NOT meant for those actively doing the problem sets. All problem set presented in here is owned by Harvard University. 10 | 11 | ––– 12 | -------------------------------------------------------------------------------- /The Odin Project/admin dashboard/images/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/The Odin Project/admin dashboard/images/avatar.png -------------------------------------------------------------------------------- /The Odin Project/admin dashboard/images/avatar2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/The Odin Project/admin dashboard/images/avatar2.png -------------------------------------------------------------------------------- /The Odin Project/admin dashboard/images/avatar3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/The Odin Project/admin dashboard/images/avatar3.png -------------------------------------------------------------------------------- /The Odin Project/admin dashboard/images/avatar4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dors-Coding-School/Coding/8f961f7a3479758645ab25feb8a518fc9723a7c1/The Odin Project/admin dashboard/images/avatar4.png -------------------------------------------------------------------------------- /The Odin Project/admin dashboard/images/images.txt: -------------------------------------------------------------------------------- 1 | The images that we used are optional. 2 | -------------------------------------------------------------------------------- /The Odin Project/etch-a-sketch/styles.css: -------------------------------------------------------------------------------- 1 | body{ 2 | display: flex; 3 | justify-content: center; 4 | align-items: center; 5 | flex-direction: column; 6 | } 7 | 8 | .header{ 9 | display: flex; 10 | flex-direction: row; 11 | align-items: center; 12 | width: 400px; 13 | justify-content: space-around; 14 | margin-bottom: 20px; 15 | } 16 | 17 | .footer{ 18 | display: flex; 19 | flex-direction: row; 20 | justify-content: space-between; 21 | width: 500px; 22 | align-items: center; 23 | margin-top: 20px; 24 | } 25 | 26 | .board{ 27 | width: 500px; 28 | height: 500px; 29 | display: grid; 30 | border: 1px solid black; 31 | } 32 | -------------------------------------------------------------------------------- /The Odin Project/library/books.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Book Library 7 | 8 | 9 | 10 | 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /The Odin Project/recipes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Odin Recipes 5 | 6 | 7 | 8 | 9 |

Odin Recipes

10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /The Odin Project/recipes/styles.css: -------------------------------------------------------------------------------- 1 | .container{ 2 | display: flex; 3 | flex-direction: column; 4 | justify-content: center; 5 | align-items: center; 6 | } 7 | 8 | h1{ 9 | text-align: center; 10 | font-size: 40px; 11 | } 12 | 13 | h3{ 14 | color: brown; 15 | margin: 0; 16 | } 17 | 18 | h4{ 19 | font-size: 25px; 20 | margin: 0; 21 | } 22 | 23 | a{ 24 | margin: 10px; 25 | color: black; 26 | font-size: 20px; 27 | } 28 | -------------------------------------------------------------------------------- /The Odin Project/rock paper scissors/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /The Odin Project/sign up form/main.js: -------------------------------------------------------------------------------- 1 | document.addEventListener("DOMContentLoaded", function(){ 2 | 3 | let password = document.querySelector("#password").value; 4 | let confirmPassword = document.querySelector("#confirmPassword").value; 5 | 6 | let error = document.querySelector("#error"); 7 | 8 | if(password == "" && confirmPassword == ""){ 9 | error.innerHTML = "*passwords do not match"; 10 | } 11 | else if(password === confirmPassword){ 12 | error.innerHTML = ""; 13 | } 14 | }) 15 | -------------------------------------------------------------------------------- /freeCodeCamp/Responsive Web Design/Survey Form/index.html: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /freeCodeCamp/Responsive Web Design/Tribute Page/index.html: -------------------------------------------------------------------------------- 1 | a 2 | --------------------------------------------------------------------------------