├── 0x15-javascript-web_jquery
├── 100-script.js
├── 1-script.js
├── 0-script.js
├── 3-script.js
├── 4-script.js
├── 6-script.js
├── 2-script.js
├── 5-script.js
├── 9-script.js
├── 7-script.js
├── 8-script.js
├── 101-script.js
├── 102-script.js
└── 103-script.js
├── 0x0C-python-almost_a_circle
├── models
│ ├── __init__.py
│ └── __pycache__
│ │ ├── base.cpython-38.pyc
│ │ ├── square.cpython-38.pyc
│ │ ├── __init__.cpython-38.pyc
│ │ └── rectangle.cpython-38.pyc
└── tests
│ └── test_models
│ ├── __init__.py
│ └── __pycache__
│ ├── __init__.cpython-38.pyc
│ ├── test_base.cpython-38.pyc
│ ├── test_square.cpython-38.pyc
│ └── test_rectangle.cpython-38.pyc
├── 0x10-python-network_0
├── 6-peak.txt
├── 1-body.sh
├── 0-body_size.sh
├── 2-delete.sh
├── 3-methods.sh
├── 4-header.sh
├── 100-status_code.sh
├── 101-post_json.sh
├── 102-catch_me.sh
├── 5-post_params.sh
├── 6-peak.py
└── README.md
├── 0x09-python-everything_is_object
├── 1-answer.txt
├── 103-line1.txt
├── 103-line2.txt
├── 104-line1.txt
├── 104-line2.txt
├── 104-line5.txt
├── 106-line1.txt
├── 106-line2.txt
├── 106-line3.txt
├── 106-line5.txt
├── 16-answer.txt
├── 2-answer.txt
├── 22-answer.txt
├── 27-answer.txt
├── 3-answer.txt
├── 4-answer.txt
├── 5-answer.txt
├── 0-answer.txt
├── 10-answer.txt
├── 104-line3.txt
├── 104-line4.txt
├── 105-line1.txt
├── 106-line4.txt
├── 11-answer.txt
├── 12-answer.txt
├── 13-answer.txt
├── 20-answer.txt
├── 21-answer.txt
├── 23-answer.txt
├── 24-answer.txt
├── 25-answer.txt
├── 26-answer.txt
├── 28-answer.txt
├── 6-answer.txt
├── 7-answer.txt
├── 8-answer.txt
├── 9-answer.txt
├── 14-answer.txt
├── 15-answer.txt
├── 17-answer.txt
├── 18-answer.txt
├── 19-copy_list.py
├── __pycache__
│ ├── 19-copy_list.cpython-38.pyc
│ ├── 100-magic_string.cpython-38.pyc
│ └── 101-locked_class.cpython-38.pyc
├── 100-magic_string.py
├── 101-locked_class.py
└── README.md
├── 0x00-python-hello_world
├── 0-run
├── 1-run_inline
├── 9-easter_egg.py
├── main.py
├── 4-print_float.py
├── 2-print.py
├── 3-print_number.py
├── 102-magic_calculation.py
├── 101-compile
├── 5-print_string.py
├── 6-concat.py
├── 100-write.py
├── 8-concat_edges.py
├── 7-edges.py
├── README.md
├── lists.h
└── 10-check_cycle.c
├── 0x02-python-import_modules
├── 0-import_add.py
├── README.md
├── variable_load_5.py
├── 103-fast_alphabet.py
├── 101-easy_print.py
├── 5-variable_load.py
├── 0-add.py
├── add_0.py
├── 4-hidden_discovery.py
├── 3-infinite_add.py
├── 102-magic_calculation.py
├── 1-calculation.py
├── 2-args.py
├── 100-my_calculator.py
└── calculator_1.py
├── 0x08-python-more_classes
├── README.md
├── .3-rectangle.py.swp
├── 0-main.py
├── __pycache__
│ ├── 0-main.cpython-38.pyc
│ ├── 1-main.cpython-38.pyc
│ ├── 2-main.cpython-38.pyc
│ ├── 3-main.cpython-38.pyc
│ ├── 0-rectangle.cpython-38.pyc
│ ├── 1-rectangle.cpython-38.pyc
│ ├── 101-nqueens.cpython-38.pyc
│ ├── 2-rectangle.cpython-38.pyc
│ ├── 3-rectangle.cpython-38.pyc
│ ├── 4-rectangle.cpython-38.pyc
│ ├── 5-rectangle.cpython-38.pyc
│ ├── 6-rectangle.cpython-38.pyc
│ ├── 7-rectangle.cpython-38.pyc
│ ├── 8-rectangle.cpython-38.pyc
│ └── 9-rectangle.cpython-38.pyc
├── 0-rectangle.py
├── 1-main.py
├── 2-main.py
└── 3-main.py
├── 0x12-javascript-warm_up
├── 100-let_me_const.js
├── 13-add.js
├── 3-value_argument.js
├── 0-javascript_is_amazing.js
├── 102-add_me_maybe.js
├── 1-multi_languages.js
├── 5-to_integer.js
├── 101-call_me_moby.js
├── 4-concat.js
├── 12-object.js
├── 10-factorial.js
├── 6-multi_languages_loop.js
├── 9-add.js
├── 2-arguments.js
├── 7-multi_c.js
├── 11-second_biggest.js
├── 8-square.js
└── 103-object_fct.js
├── 0x03-python-data_structures
├── README.md
├── 12-switch.py
├── 0-print_list_integer.py
├── 5-main.py
├── __pycache__
│ ├── 5-no_c.cpython-38.pyc
│ ├── 7-add_tuple.cpython-38.pyc
│ ├── 1-element_at.cpython-38.pyc
│ ├── 11-delete_at.cpython-38.pyc
│ ├── 4-new_in_list.cpython-38.pyc
│ ├── 9-max_integer.cpython-38.pyc
│ ├── 10-divisible_by_2.cpython-38.pyc
│ ├── 2-replace_in_list.cpython-38.pyc
│ ├── 8-multiple_returns.cpython-38.pyc
│ ├── 0-print_list_integer.cpython-38.pyc
│ ├── 6-print_matrix_integer.cpython-38.pyc
│ └── 3-print_reversed_list_integer.cpython-38.pyc
├── 11-delete_at.py
├── 0-main.py
├── 1-element_at.py
├── 1-main.py
├── 11-main.py
├── 3-main.py
├── 3-print_reversed_list_integer.py
├── 5-no_c.py
├── 9-main.py
├── 8-multiple_returns.py
├── 2-replace_in_list.py
├── 4-main.py
├── 8-main.py
├── 2-main.py
├── 7-main.py
├── 6-main.py
├── 10-divisible_by_2.py
├── 4-new_in_list.py
├── 9-max_integer.py
├── 10-main.py
├── 6-print_matrix_integer.py
├── 7-add_tuple.py
├── 100-print_python_list_info.c
├── lists.h
├── 13-main.c
└── 13-is_palindrome.c
├── 0x05-python-exceptions
├── README.md
├── 5-raise_exception.py
├── 6-raise_exception_msg.py
├── 1-safe_print_integer.py
├── 101-safe_function.py
├── 0-safe_print_list.py
├── 3-safe_print_division.py
├── 100-safe_print_integer_err.py
├── 3-main.py
├── 2-safe_print_list_integers.py
├── 102-magic_calculation.py
├── 0-main.py
├── 1-main.py
├── 2-main.py
└── 4-list_division.py
├── 0x01-python-if_else_loops_functions
├── README.md
├── 10-add.py
├── 11-pow.py
├── 4-print_hexa.py
├── 2-print_alphabet.py
├── 5-print_comb2.py
├── 101-remove_char_at.py
├── 7-islower.py
├── 3-print_alphabt.py
├── 102-magic_calculation.py
├── 100-print_tebahpla.py
├── 8-uppercase.py
├── 6-print_comb3.py
├── 0-positive_or_negative.py
├── 9-print_last_digit.py
├── 12-fizzbuzz.py
├── 1-last_digit.py
├── lists.h
└── 13-insert_number.c
├── 0x04-python-more_data_structures
├── README.md
├── 5-number_keys.py
├── 3-common_elements.py
├── 4-only_diff_elements.py
├── 9-multiply_by_2.py
├── 10-best_score.py
├── 11-multiply_list_map.py
├── 7-update_dictionary.py
├── 0-square_matrix_simple.py
├── 101-square_matrix_map.py
├── 2-uniq_add.py
├── __pycache__
│ ├── 0-main.cpython-38.pyc
│ ├── 1-main.cpython-38.pyc
│ ├── 2-main.cpython-38.pyc
│ ├── 3-main.cpython-38.pyc
│ ├── 4-main.cpython-38.pyc
│ ├── 5-main.cpython-38.pyc
│ ├── 6-main.cpython-38.pyc
│ ├── 7-main.cpython-38.pyc
│ ├── 8-main.cpython-38.pyc
│ ├── 9-main.cpython-38.pyc
│ ├── 10-main.cpython-38.pyc
│ ├── 100-main.cpython-38.pyc
│ ├── 101-main.cpython-38.pyc
│ ├── 102-main.cpython-38.pyc
│ ├── 11-main.cpython-38.pyc
│ ├── 12-main.cpython-38.pyc
│ ├── 2-uniq_add.cpython-38.pyc
│ ├── 10-best_score.cpython-38.pyc
│ ├── 5-number_keys.cpython-38.pyc
│ ├── 1-search_replace.cpython-38.pyc
│ ├── 12-roman_to_int.cpython-38.pyc
│ ├── 8-simple_delete.cpython-38.pyc
│ ├── 9-multiply_by_2.cpython-38.pyc
│ ├── search_replace.cpython-38.pyc
│ ├── 100-weight_average.cpython-38.pyc
│ ├── 102-complex_delete.cpython-38.pyc
│ ├── 3-common_elements.cpython-38.pyc
│ ├── 101-square_matrix_map.cpython-38.pyc
│ ├── 11-multiply_list_map.cpython-38.pyc
│ ├── 4-only_diff_elements.cpython-38.pyc
│ ├── 7-update_dictionary.cpython-38.pyc
│ ├── 0-square_matrix_simple.cpython-38.pyc
│ └── 6-print_sorted_dictionary.cpython-38.pyc
├── 8-simple_delete.py
├── 2-main.py
├── 6-print_sorted_dictionary.py
├── 11-main.py
├── 1-search_replace.py
├── search_replace.py
├── 1-main.py
├── 5-main.py
├── 3-main.py
├── 6-main.py
├── 4-main.py
├── 0-main.py
├── 100-main.py
├── 101-main.py
├── 100-weight_average.py
├── 102-complex_delete.py
├── 10-main.py
├── 9-main.py
├── 12-roman_to_int.py
├── 102-main.py
├── 8-main.py
├── 12-main.py
└── 7-main.py
├── 0x06-python-classes
├── README.md
├── 0-main.py
├── 0-square.py
├── 5-main.py
├── 6-main.py
├── 1-main.py
├── 1-square.py
├── 3-main.py
├── 100-main.py
├── 4-main.py
├── 103-magic_class.py
├── 2-square.py
├── 2-main.py
├── 3-square.py
└── 4-square.py
├── 0x13-javascript_objects_scopes_closures
├── README.md
├── 100-data.js
├── 0-rectangle.js
├── 101-data.js
├── 9-logme.js
├── 100-map.js
├── 10-converter.js
├── 8-esrever.js
├── 1-rectangle.js
├── 7-occurrences.js
├── 5-square.js
├── 2-rectangle.js
├── 101-sorted.js
├── 6-square.js
├── 3-rectangle.js
├── 102-concat.js
└── 4-rectangle.js
├── 0x0D-SQL_introduction
├── 0-list_databases.sql
├── 3-list_tables.sql
├── 6-list_values.sql
├── 2-remove_database.sql
├── 5-full_table.sql
├── 1-create_database_if_missing.sql
├── 13-change_class.sql
├── 7-insert_value.sql
├── 14-average.sql
├── 12-no_cheating.sql
├── 8-count_89.sql
├── 4-first_table.sql
├── 100-move_to_utf8.sql
├── 10-top_score.sql
├── 103-max_state.sql
├── 101-avg_temperatures.sql
├── 16-no_link.sql
├── 11-best_score.sql
├── 15-groups.sql
├── 102-top_city.sql
└── 9-full_creation.sql
├── 0x14-javascript-web_scraping
├── package.json
├── 1-writeme.js
├── 0-readme.js
├── 2-statuscode.js
├── 3-starwars_title.js
├── 5-request_store.js
├── 4-starwars_count.js
├── 101-starwars_characters.js
├── 100-starwars_characters.js
├── README.md
└── 6-completed_tasks.js
├── 0x0A-python-inheritance
├── 5-base_geometry.py
├── __pycache__
│ ├── 0-lookup.cpython-38.pyc
│ ├── 1-my_list.cpython-38.pyc
│ ├── 10-square.cpython-38.pyc
│ ├── 100-my_int.cpython-38.pyc
│ ├── 11-square.cpython-38.pyc
│ ├── 8-rectangle.cpython-38.pyc
│ ├── 9-rectangle.cpython-38.pyc
│ ├── 2-is_same_class.cpython-38.pyc
│ ├── 4-inherits_from.cpython-38.pyc
│ ├── 5-base_geometry.cpython-38.pyc
│ ├── 6-base_geometry.cpython-38.pyc
│ ├── 7-base_geometry.cpython-38.pyc
│ ├── 101-add_attribute.cpython-38.pyc
│ └── 3-is_kind_of_class.cpython-38.pyc
├── 0-lookup.py
├── 6-base_geometry.py
├── 1-my_list.py
├── 2-is_same_class.py
├── 101-add_attribute.py
├── 3-is_kind_of_class.py
├── 100-my_int.py
├── 11-square.py
├── 4-inherits_from.py
├── 10-square.py
├── 8-rectangle.py
├── 7-base_geometry.py
└── 9-rectangle.py
├── 0x0F-python-object_relational_mapping
├── README.md
├── 6-model_state.sql
├── 6-model_state.py
├── 0-select_states.py
├── model_state.py
├── model_city.py
├── relationship_city.py
├── 1-filter_states.py
├── 7-model_state_fetch_all.py
├── 12-model_state_update_id_2.py
├── 11-model_state_insert.py
├── 2-my_filter_states.py
├── 10-model_state_my_get.py
├── 102-relationship_cities_states_list.py
├── relationship_state.py
├── 8-model_state_fetch_first.py
├── 4-cities_by_state.py
├── 9-model_state_filter_a.py
├── 13-model_state_delete_a.py
├── 3-my_safe_filter_states.py
├── 14-model_city_fetch_by_state.py
├── 100-relationship_states_cities.py
├── 101-relationship_states_cities_list.py
└── 5-filter_cities.py
├── 0x0E-SQL_more_queries
├── 0-privileges.sql
├── 4-never_empty.sql
├── 5-unique_id.sql
├── 3-force_name.sql
├── 1-create_user.sql
├── 9-cities_by_state_join.sql
├── 8-cities_of_california_subquery.sql
├── 102-rating_shows.sql
├── 11-genre_id_all_shows.sql
├── 2-create_read_user.sql
├── 10-genre_id_by_show.sql
├── 16-shows_by_genre.sql
├── 12-no_genre.sql
├── 6-states.sql
├── 13-count_shows_by_genre.sql
├── 15-comedy_only.sql
├── 103-rating_genres.sql
├── 14-my_genres.sql
├── 101-not_a_comedy.sql
├── 7-cities.sql
└── 100-not_my_genres.sql
├── killer-push.sh
├── 0x07-python-test_driven_development
├── __pycache__
│ ├── 0-main.cpython-38.pyc
│ ├── 100-main.cpython-38.pyc
│ ├── 101-main.cpython-38.pyc
│ ├── 2-main.cpython-38.pyc
│ ├── 3-main.cpython-38.pyc
│ ├── 4-main.cpython-38.pyc
│ ├── 5-main.cpython-38.pyc
│ ├── 102-tests.cpython-38.pyc
│ ├── 0-add_integer.cpython-38.pyc
│ ├── 3-say_my_name.cpython-38.pyc
│ ├── 6-max_integer.cpython-38.pyc
│ ├── 100-matrix_mul.cpython-38.pyc
│ ├── 4-print_square.cpython-38.pyc
│ ├── 2-matrix_divided.cpython-38.pyc
│ ├── 5-text_indentation.cpython-38.pyc
│ └── 101-lazy_matrix_mul.cpython-38.pyc
├── 100-main.py
├── 2-main.py
├── 101-main.py
├── 3-main.py
├── 4-main.py
├── 0-main.py
├── 101-lazy_matrix_mul.py
├── 6-max_integer_test.py
├── 102-tests.py
├── 0-add_integer.py
├── 3-say_my_name.py
├── 102-python.c
├── 5-main.py
├── 4-print_square.py
└── 5-text_indentation.py
├── 0x0B-python-input_output
├── 3-to_json_string.py
├── 8-class_to_json.py
├── 2-append_write.py
├── 4-from_json_string.py
├── 6-load_from_json_file.py
├── 0-read_file.py
├── 5-save_to_json_file.py
├── 1-write_file.py
├── 9-student.py
├── 12-pascal_triangle.py
├── 7-add_item.py
├── 100-append_after.py
├── 11-student.py
└── 10-student.py
├── 0x11-python-network_1
├── 4-hbtn_status.py
├── 5-hbtn_header.py
├── 6-post_email.py
├── 10-my_github.py
├── 0-hbtn_status.py
├── 3-error_code.py
├── 7-error_code.py
├── 1-hbtn_header.py
├── 2-post_email.py
├── 8-json_api.py
└── 100-github_commits.py
└── README.md
/0x15-javascript-web_jquery/100-script.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/models/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/0x10-python-network_0/6-peak.txt:
--------------------------------------------------------------------------------
1 | O(log(n))
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/1-answer.txt:
--------------------------------------------------------------------------------
1 | id
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/103-line1.txt:
--------------------------------------------------------------------------------
1 | 0
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/103-line2.txt:
--------------------------------------------------------------------------------
1 | 0
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/104-line1.txt:
--------------------------------------------------------------------------------
1 | 1
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/104-line2.txt:
--------------------------------------------------------------------------------
1 | 1
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/104-line5.txt:
--------------------------------------------------------------------------------
1 | 1
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/106-line1.txt:
--------------------------------------------------------------------------------
1 | 1
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/106-line2.txt:
--------------------------------------------------------------------------------
1 | 0
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/106-line3.txt:
--------------------------------------------------------------------------------
1 | No
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/106-line5.txt:
--------------------------------------------------------------------------------
1 | 1
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/16-answer.txt:
--------------------------------------------------------------------------------
1 | 1
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/2-answer.txt:
--------------------------------------------------------------------------------
1 | NO
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/22-answer.txt:
--------------------------------------------------------------------------------
1 | No
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/27-answer.txt:
--------------------------------------------------------------------------------
1 | No
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/3-answer.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/4-answer.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/5-answer.txt:
--------------------------------------------------------------------------------
1 | No
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/0-answer.txt:
--------------------------------------------------------------------------------
1 | type
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/10-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/104-line3.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/104-line4.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/105-line1.txt:
--------------------------------------------------------------------------------
1 | 262
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/106-line4.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/11-answer.txt:
--------------------------------------------------------------------------------
1 | False
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/12-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/13-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/20-answer.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/21-answer.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/23-answer.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/24-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/25-answer.txt:
--------------------------------------------------------------------------------
1 | False
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/26-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/28-answer.txt:
--------------------------------------------------------------------------------
1 | Yes
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/6-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/7-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/8-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/9-answer.txt:
--------------------------------------------------------------------------------
1 | True
2 |
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/tests/test_models/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/14-answer.txt:
--------------------------------------------------------------------------------
1 | [1, 2, 3, 4]
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/15-answer.txt:
--------------------------------------------------------------------------------
1 | [1, 2, 3]
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/17-answer.txt:
--------------------------------------------------------------------------------
1 | [1, 2, 3, 4]
2 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/18-answer.txt:
--------------------------------------------------------------------------------
1 | [1, 2, 3]
2 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/0-run:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | python3 ./$PYFILE
3 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/0-import_add.py:
--------------------------------------------------------------------------------
1 | __import__("0-add")
2 |
--------------------------------------------------------------------------------
/0x08-python-more_classes/README.md:
--------------------------------------------------------------------------------
1 | ## More Classes in Python
2 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/1-run_inline:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | python3 -c "$PYCODE"
3 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/9-easter_egg.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | import this
3 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | print("Best School")
3 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/100-let_me_const.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | myVar = 333;
3 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/README.md:
--------------------------------------------------------------------------------
1 | ## Solution to tasks on Python data structures
2 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/README.md:
--------------------------------------------------------------------------------
1 | ## Solution to tasks on 0x05. Python - Exceptions
2 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/13-add.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | exports.add = (a, b) => a + b;
3 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/README.md:
--------------------------------------------------------------------------------
1 | Solution to tasks on conditionals & loops
2 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/README.md:
--------------------------------------------------------------------------------
1 | ## Solutions to tasks on More Data structures
2 |
--------------------------------------------------------------------------------
/0x06-python-classes/README.md:
--------------------------------------------------------------------------------
1 | ## Solutions to tasks on 0x06. Python - Classes and Objects
2 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/README.md:
--------------------------------------------------------------------------------
1 | JavaScript - Objects, Scopes and Closures
2 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/100-data.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | exports.list = [1, 2, 3, 4, 5];
3 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/10-add.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def add(a, b):
3 | return (a + b)
4 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/11-pow.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def pow(a, b):
3 | return (a ** b)
4 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/README.md:
--------------------------------------------------------------------------------
1 | # Solutions to tasks on modules
2 | ___
3 | Python - import & modules
4 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/variable_load_5.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | a = 98
3 | """Simple variable
4 | """
5 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/0-list_databases.sql:
--------------------------------------------------------------------------------
1 | -- Lists all databases of my MySQL server.
2 | SHOW DATABASES;
3 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/4-print_float.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | number = 3.14159
3 | print(f"Float: {number:.2f}")
4 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/3-list_tables.sql:
--------------------------------------------------------------------------------
1 | -- Lists all tables of a database on my MySQL server.
2 | SHOW TABLES;
3 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "request": "^2.88.2"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/2-print.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | print('"Programming is like building a multilingual puzzle')
3 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/3-print_number.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | number = 98
3 | print(f"{number:d} Battery street")
4 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/103-fast_alphabet.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | import string
3 | print(string.ascii_uppercase)
4 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/19-copy_list.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def copy_list(z):
3 | return (z.copy())
4 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/1-script.js:
--------------------------------------------------------------------------------
1 | document.readyState(function () {
2 | $('header').css('color', '#FF0000');
3 | });
4 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/102-magic_calculation.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def magic_calculation(a, b):
3 | return (98 + a ** b)
4 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/101-easy_print.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | __import__("os").write(1, "#pythoniscool\n".encode("UTF-8"))
3 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/3-value_argument.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | console.log(process.argv[2] ? process.argv[2] : 'No argument');
3 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/0-script.js:
--------------------------------------------------------------------------------
1 | const header = document.querySelector('header');
2 |
3 | header.style.color = '#FF0000';
4 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/101-compile:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | python3 -c "import py_compile; py_compile.compile('$PYFILE', '$PYFILE' + 'c')"
3 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/5-print_string.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | str = "Holberton School"
3 | print(str + str + str)
4 | print(str[:9])
5 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/12-switch.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | a = 89
3 | b = 10
4 | a, b = b, a
5 | print("a={:d} - b={:d}".format(a, b))
6 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/5-number_keys.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def number_keys(a_dictionary):
3 | return len(a_dictionary)
4 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/6-list_values.sql:
--------------------------------------------------------------------------------
1 | -- Lists all rows of the table first_table in my MySQL server.
2 | SELECT * FROM `first_table`;
3 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/0-javascript_is_amazing.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const myVar = 'JavaScript is amazing';
4 | console.log(myVar);
5 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/3-common_elements.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def common_elements(set_1, set_2):
3 | return (set_1 & set_2)
4 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/2-remove_database.sql:
--------------------------------------------------------------------------------
1 | -- Deletes the database hbtn_0c_0 from my MySQL server.
2 | DROP DATABASE IF EXISTS `hbtn_0c_0`;
3 |
--------------------------------------------------------------------------------
/0x10-python-network_0/1-body.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # send a GET request to an URL with curl, and display the body of the response
3 | curl -sL "$1"
4 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/4-print_hexa.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | for num in range(0, 99):
3 | print('{} = 0x{:x}'.format(num, num))
4 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/4-only_diff_elements.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def only_diff_elements(set_1, set_2):
3 | return (set_1 ^ set_2)
4 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/5-full_table.sql:
--------------------------------------------------------------------------------
1 | -- Prints the full description of the table first_table in my MySQL server.
2 | SHOW CREATE TABLE `first_table`;
3 |
--------------------------------------------------------------------------------
/0x10-python-network_0/0-body_size.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Get the comtent-lenght of a giving ip address
3 | curl -sI "$1" | awk '/Content-Length/{print $2}'
4 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/102-add_me_maybe.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | exports.addMeMaybe = function (number, theFunction) {
3 | theFunction(++number);
4 | };
5 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/6-concat.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | str1 = "Holberton"
3 | str2 = "School"
4 | str1 = str1 + " " + str2
5 | print(f"Welcome to {str1}!")
6 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/2-print_alphabet.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | for i in range(ord('a'), ord('z') + 1):
3 | print('{:c}'.format(i), end='')
4 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/5-raise_exception.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def raise_exception():
3 | """Raise a TypeError exception."""
4 | raise TypeError
5 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/1-create_database_if_missing.sql:
--------------------------------------------------------------------------------
1 | -- Creates the database hbtn_0c_0 in my MySQL server.
2 | CREATE DATABASE IF NOT EXISTS `hbtn_0c_0`;
3 |
--------------------------------------------------------------------------------
/0x10-python-network_0/2-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # send a DELETE request to an URL with curl and display the body of the response
3 | curl -sX DELETE "$1"
4 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/1-multi_languages.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const myVar = 'C is fun\nPython is cool\nJavaScript is amazing';
4 | console.log(myVar);
5 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/5-print_comb2.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | for num in range(0, 99):
3 | print('{:02d}, '.format(num), end='')
4 | print('99')
5 |
--------------------------------------------------------------------------------
/0x08-python-more_classes/.3-rectangle.py.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/.3-rectangle.py.swp
--------------------------------------------------------------------------------
/0x10-python-network_0/3-methods.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # display all HTTP methods the server will accept using curl.
3 | curl -sI "$1" | grep "Allow" | cut -d " " -f 2-
4 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/5-to_integer.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | console.log(parseInt(process.argv[2]) ? `My number: ${parseInt(process.argv[2])}` : 'Not a number');
3 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/101-call_me_moby.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | exports.callMeMoby = function (x, theFunction) {
3 | for (let i = 0; i < x; i++) theFunction();
4 | };
5 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/4-concat.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const argv0 = process.argv[2];
3 | const argv1 = process.argv[3];
4 |
5 | console.log(`${argv0} is ${argv1}`);
6 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/3-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $("DIV#red_header").click(function () {
3 | $("header").addClass("red");
4 | });
5 | });
6 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/100-write.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | import sys
3 | sys.stderr.write("and that piece of art is useful - Dora Korpar, 2015-10-19\n")
4 | sys.exit(1)
5 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/9-multiply_by_2.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def multiply_by_2(a_dictionary):
3 | return {key: val * 2 for key, val in a_dictionary.items()}
4 |
--------------------------------------------------------------------------------
/0x10-python-network_0/4-header.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # send a GET request to the URL using curl, and display the body of the response
3 | curl -sH "X-School-User-Id: 98" "$1"
4 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/0-print_list_integer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def print_list_integer(my_list=[]):
4 | for i in my_list:
5 | print('{:d}'.format(i))
6 |
--------------------------------------------------------------------------------
/0x06-python-classes/0-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Square = __import__('0-square').Square
3 |
4 | my_square = Square()
5 | print(type(my_square))
6 | print(my_square.__dict__)
7 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/0-rectangle.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | /**
3 | * Represents a rectangle
4 | */
5 | class Rectangle {}
6 |
7 | module.exports = Rectangle;
8 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/4-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $("DIV#toggle_header").click(function () {
3 | $("header").toggleClass("red green");
4 | });
5 | });
6 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/6-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $("DIV#update_header").click(function () {
3 | $("header").text("New Header!!!");
4 | });
5 | });
6 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/10-best_score.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def best_score(a_dictionary):
3 | return max(a_dictionary, key=a_dictionary.get) if a_dictionary else None
4 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/11-multiply_list_map.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def multiply_list_map(my_list=[], number=0):
3 | return list(map(lambda x: x * number, my_list))
4 |
--------------------------------------------------------------------------------
/0x06-python-classes/0-square.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # 0-square.py by UDO INNOCENT
3 | """Defines a square """
4 |
5 |
6 | class Square:
7 | """Does nothing"""
8 | pass
9 |
--------------------------------------------------------------------------------
/0x08-python-more_classes/0-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Rectangle = __import__('0-rectangle').Rectangle
3 |
4 | rect = Rectangle()
5 | print(type(rect))
6 | print(rect.__dict__)
7 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/5-base_geometry.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines an empty class BaseGeometry."""
3 |
4 |
5 | class BaseGeometry:
6 | """Empty class"""
7 | pass
8 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/13-change_class.sql:
--------------------------------------------------------------------------------
1 | -- Removes all records with a score <= 5 in the table second_table in my MySQL server.
2 | DELETE FROM `second_table`
3 | WHERE `score` <= 5;
4 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/7-insert_value.sql:
--------------------------------------------------------------------------------
1 | -- Inserts a new row into the table first_table in my MySQL server.
2 | INSERT INTO `first_table` (`id`, `name`) VALUES (89, "Best School");
3 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/README.md:
--------------------------------------------------------------------------------
1 | # Python Object Relational Mapping
2 |
3 |
4 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/101-data.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | exports.dict = {
3 | 89: 1,
4 | 90: 2,
5 | 91: 1,
6 | 92: 3,
7 | 93: 1,
8 | 94: 2
9 | };
10 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/2-script.js:
--------------------------------------------------------------------------------
1 | document.readyState(function () {
2 | $('DIV#red_header').click(function () {
3 | $('header'.css('color', '#FF0000'));
4 | });
5 | });
6 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/5-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $("DIV#add_item").click(function () {
3 | $("
").text("Item").appendTo("ul.my_list");
4 | });
5 | });
6 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/101-remove_char_at.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def remove_char_at(str, n):
3 | if n < 0:
4 | return (str)
5 | return (str[:n] + str[n+1:])
6 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/5-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | no_c = __import__('5-no_c').no_c
3 |
4 | print(no_c("Best School"))
5 | print(no_c("Chicago"))
6 | print(no_c("C is fun!"))
7 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/7-update_dictionary.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def update_dictionary(a_dictionary, key, value):
3 | a_dictionary[key] = value
4 | return a_dictionary
5 |
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/0-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/0-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/1-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/1-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/2-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/2-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/3-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/3-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/14-average.sql:
--------------------------------------------------------------------------------
1 | -- Computes the average score of all records in the table second_table in my MySQL server.
2 | SELECT AVG(`score`) AS `average`
3 | FROM `second_table`;
4 |
--------------------------------------------------------------------------------
/0x10-python-network_0/100-status_code.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Sends a request to a URL passed as an argument, and displays only the status code
3 | curl -s -o /dev/null -w "%{http_code}" "$1"
4 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/7-islower.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def islower(c):
3 | if ord(c) >= 97 and ord(c) <= 122:
4 | return True
5 | else:
6 | return False
7 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/5-no_c.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/5-no_c.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/0-square_matrix_simple.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def square_matrix_simple(matrix=[]):
4 | return [list(map(lambda x: x ** 2, row)) for row in matrix]
5 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/0-lookup.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/0-lookup.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/1-my_list.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/1-my_list.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/10-square.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/10-square.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/100-my_int.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/100-my_int.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/11-square.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/11-square.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/12-no_cheating.sql:
--------------------------------------------------------------------------------
1 | -- Updates the score of Bob to 10 in the table second_table in my MySQL server.
2 | UPDATE `second_table`
3 | SET `score` = 10
4 | WHERE `name` = "Bob";
5 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/8-count_89.sql:
--------------------------------------------------------------------------------
1 | -- Displays the number of records with id = 89 in the table first_table in my MySQL server.
2 | SELECT COUNT(*)
3 | FROM `first_table`
4 | WHERE `id` = 89;
5 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/11-delete_at.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def delete_at(my_list=[], idx=0):
4 | if 0 <= idx < len(my_list):
5 | del(my_list[idx])
6 | return (my_list)
7 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/101-square_matrix_map.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def square_matrix_map(matrix=[]):
3 | return list(map((lambda row: list(map((lambda x: x * x), row))), matrix))
4 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/6-raise_exception_msg.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def raise_exception_msg(message=""):
3 | """Raise a NameError exception with a message."""
4 | raise NameError(message)
5 |
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/0-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/0-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/1-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/1-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/101-nqueens.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/101-nqueens.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/2-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/2-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/3-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/3-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/4-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/4-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/5-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/5-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/6-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/6-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/7-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/7-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/8-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/8-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/__pycache__/9-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x08-python-more_classes/__pycache__/9-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/8-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/8-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/9-rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/9-rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/4-first_table.sql:
--------------------------------------------------------------------------------
1 | -- Creates a table called first_table with values id and name in my MySQL server.
2 | CREATE TABLE IF NOT EXISTS `first_table` (`id` INT, `name` VARCHAR(256));
3 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/0-privileges.sql:
--------------------------------------------------------------------------------
1 | -- Lists all privileges of the MySQL users user_0d_1 and user_0d_2
2 | SHOW GRANTS FOR 'user_0d_1'@'localhost';
3 | SHOW GRANTS FOR 'user_0d_2'@'localhost';
4 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/4-never_empty.sql:
--------------------------------------------------------------------------------
1 | -- creates the table id_not_null on your MySQL server
2 | -- creates a table
3 | CREATE TABLE IF NOT EXISTS id_not_null (id INT DEFAULT 1, name VARCHAR(256));
4 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/5-unique_id.sql:
--------------------------------------------------------------------------------
1 | -- creates the table unique_id on your MySQL server
2 | -- creates a table
3 | CREATE TABLE IF NOT EXISTS unique_id (id INT DEFAULT 1 UNIQUE, name VARCHAR(256));
4 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/12-object.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const myObject = {
3 | type: 'object',
4 | value: 12
5 | };
6 | console.log(myObject);
7 | myObject.value = 89;
8 | console.log(myObject);
9 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/0-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | print_list_integer = __import__('0-print_list_integer').print_list_integer
3 |
4 | my_list = [1, 2, 3, 4, 5]
5 | print_list_integer(my_list)
6 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/7-add_tuple.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/7-add_tuple.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/2-uniq_add.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def uniq_add(my_list=[]):
3 | number = 0
4 | for element in set(my_list):
5 | number += element
6 | return number
7 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/0-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/0-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/1-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/1-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/2-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/2-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/3-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/3-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/4-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/4-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/5-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/5-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/6-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/6-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/7-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/7-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/8-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/8-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/9-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/9-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x08-python-more_classes/0-rectangle.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """A class that defines a rectangle"""
3 |
4 |
5 | class Rectangle:
6 | """An empty class that represents a rectangle"""
7 | pass
8 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/2-is_same_class.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/2-is_same_class.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/4-inherits_from.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/4-inherits_from.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/5-base_geometry.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/5-base_geometry.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/6-base_geometry.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/6-base_geometry.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/7-base_geometry.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/7-base_geometry.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/models/__pycache__/base.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0C-python-almost_a_circle/models/__pycache__/base.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/6-model_state.sql:
--------------------------------------------------------------------------------
1 | -- Create database hbtn_0e_6_usa
2 | CREATE DATABASE IF NOT EXISTS hbtn_0e_6_usa;
3 |
4 | USE hbtn_0e_6_usa;
5 |
6 | SHOW CREATE TABLE states;
7 |
--------------------------------------------------------------------------------
/killer-push.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Hi Boss Innocent Charles, kindly Enter your commit message"
4 | read message
5 |
6 |
7 | git add .
8 | git commit -m "$message"
9 | git push
10 |
11 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/3-print_alphabt.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | for i in range(ord('a'), ord('z') + 1):
3 | if chr(i) != 'e' and chr(i) != 'q':
4 | print('{:c}'.format(i), end='')
5 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/1-element_at.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/1-element_at.cpython-38.pyc
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/11-delete_at.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/11-delete_at.cpython-38.pyc
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/4-new_in_list.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/4-new_in_list.cpython-38.pyc
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/9-max_integer.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/9-max_integer.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/8-simple_delete.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def simple_delete(a_dictionary, key=""):
3 | if key in a_dictionary:
4 | del a_dictionary[key]
5 | return a_dictionary
6 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/10-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/10-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/100-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/100-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/101-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/101-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/102-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/102-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/11-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/11-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/12-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/12-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/101-add_attribute.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/101-add_attribute.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/models/__pycache__/square.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0C-python-almost_a_circle/models/__pycache__/square.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/100-move_to_utf8.sql:
--------------------------------------------------------------------------------
1 | -- Converts the entire database hbtn_0c_0 to UTF8.
2 | USE `hbtn_0c_0`
3 | ALTER TABLE `first_table`
4 | CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
5 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/3-force_name.sql:
--------------------------------------------------------------------------------
1 | -- creates the table force_name on your MySQL server
2 | -- creates a table in a database
3 | CREATE TABLE IF NOT EXISTS force_name (id INT, name VARCHAR(256) NOT NULL);
4 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/10-factorial.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | function factorial (n) {
3 | return n === 0 || isNaN(n) ? 1 : n * factorial(n - 1);
4 | }
5 |
6 | console.log(factorial(Number(process.argv[2])));
7 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/9-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $.getJSON("https://fourtonfish.com/hellosalut/?lang=fr", function (data) {
3 | $("DIV#hello").text(data.hello);
4 | });
5 | });
6 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/2-uniq_add.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/2-uniq_add.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/0-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/0-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/100-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/100-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/101-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/101-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/2-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/2-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/3-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/3-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/4-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/4-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/5-main.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/5-main.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0A-python-inheritance/__pycache__/3-is_kind_of_class.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0A-python-inheritance/__pycache__/3-is_kind_of_class.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/models/__pycache__/__init__.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0C-python-almost_a_circle/models/__pycache__/__init__.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/models/__pycache__/rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0C-python-almost_a_circle/models/__pycache__/rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/10-top_score.sql:
--------------------------------------------------------------------------------
1 | -- Lists all records of the table second_table.
2 | -- Records are ordered by descending score.
3 | SELECT `score`, `name`
4 | FROM `second_table`
5 | ORDER BY `score` DESC;
6 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/6-multi_languages_loop.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const myVar = ['C is fun', 'Python is cool', 'JavaScript is amazing'];
3 |
4 | myVar.forEach((element) => {
5 | console.log(element);
6 | });
7 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/9-logme.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | let counter = 0;
4 |
5 | exports.logMe = function count (item) {
6 | console.log(`${counter}: ${item}`);
7 | counter += 1;
8 | };
9 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/5-variable_load.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | if __name__ == "__main__":
3 | """Print the value of variable a from variable_load_5."""
4 | from variable_load_5 import a
5 | print(a)
6 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/1-element_at.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def element_at(my_list, idx):
4 | if idx < 0 or idx >= len(my_list):
5 | return ("None")
6 | else:
7 | return my_list[idx]
8 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/10-divisible_by_2.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/10-divisible_by_2.cpython-38.pyc
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/2-replace_in_list.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/2-replace_in_list.cpython-38.pyc
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/8-multiple_returns.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/8-multiple_returns.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/10-best_score.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/10-best_score.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/5-number_keys.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/5-number_keys.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/102-tests.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/102-tests.cpython-38.pyc
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/__pycache__/19-copy_list.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x09-python-everything_is_object/__pycache__/19-copy_list.cpython-38.pyc
--------------------------------------------------------------------------------
/0x10-python-network_0/101-post_json.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Send JSON POST request to a URL passed as the first argument, and displays the body of the response.
3 | curl -s -H "Content-Type: application/json" -d @"$2" "$1"
4 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/0-add.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | if __name__ == "__main__":
3 | """Print the sum of 1 and 2."""
4 | from add_0 import add
5 | a = 1
6 | b = 2
7 | print("{} + {} = {}".format(a, b, add(a, b)))
8 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/0-print_list_integer.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/0-print_list_integer.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/2-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | uniq_add = __import__('2-uniq_add').uniq_add
3 |
4 | my_list = [1, 2, 3, 1, 4, 2, 5]
5 | result = uniq_add(my_list)
6 | print("Result: {:d}".format(result))
7 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/1-search_replace.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/1-search_replace.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/12-roman_to_int.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/12-roman_to_int.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/8-simple_delete.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/8-simple_delete.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/9-multiply_by_2.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/9-multiply_by_2.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/search_replace.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/search_replace.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/0-add_integer.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/0-add_integer.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/3-say_my_name.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/3-say_my_name.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/6-max_integer.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/6-max_integer.cpython-38.pyc
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/__pycache__/100-magic_string.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x09-python-everything_is_object/__pycache__/100-magic_string.cpython-38.pyc
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/__pycache__/101-locked_class.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x09-python-everything_is_object/__pycache__/101-locked_class.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/103-max_state.sql:
--------------------------------------------------------------------------------
1 | -- Displays the max temperature of each state, ordered by state name.
2 | SELECT `state`, MAX(`value`) AS `max_temp`
3 | FROM `temperatures`
4 | GROUP BY `state`
5 | ORDER BY `state`;
6 |
--------------------------------------------------------------------------------
/0x10-python-network_0/102-catch_me.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Makes a request to 0.0.0.0:5000/catch_me that gets the message "You got me!".
3 | curl -sL -X PUT -H "Origin: HolbertonSchool" -d "user_id=98" 0.0.0.0:5000/catch_me
4 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/100-map.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const list = require('./100-data.js').list;
3 |
4 | const newList = list.map((val, idx) => val * idx);
5 | console.log(list);
6 | console.log(newList);
7 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/102-magic_calculation.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def magic_calculation(a, b, c):
3 | if a < b:
4 | return (c)
5 | if c > b:
6 | return (a + b)
7 | return (a*b - c)
8 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/6-print_matrix_integer.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/6-print_matrix_integer.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/100-weight_average.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/100-weight_average.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/102-complex_delete.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/102-complex_delete.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/3-common_elements.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/3-common_elements.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/100-matrix_mul.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/100-matrix_mul.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/4-print_square.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/4-print_square.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/101-square_matrix_map.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/101-square_matrix_map.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/11-multiply_list_map.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/11-multiply_list_map.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/4-only_diff_elements.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/4-only_diff_elements.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/7-update_dictionary.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/7-update_dictionary.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/2-matrix_divided.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/2-matrix_divided.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/5-text_indentation.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/5-text_indentation.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/tests/test_models/__pycache__/__init__.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0C-python-almost_a_circle/tests/test_models/__pycache__/__init__.cpython-38.pyc
--------------------------------------------------------------------------------
/0x10-python-network_0/5-post_params.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # send a POST request to the passed URL using curl, and display the body of the response
3 | curl -s -X POST -d "email=test@gmail.com&subject=I will always be here for PLD" "$1"
4 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/9-add.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const a = process.argv[2];
3 | const b = process.argv[3];
4 |
5 | function add (a, b) {
6 | return (a + b);
7 | }
8 |
9 | console.log(add(parseInt(a), parseInt(b)));
10 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/1-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | element_at = __import__('1-element_at').element_at
3 |
4 | my_list = [1, 2, 3, 4, 5]
5 | idx = 3
6 | print("Element at index {:d} is {}".format(idx, element_at(my_list, idx)))
7 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/11-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | delete_at = __import__('11-delete_at').delete_at
3 |
4 | my_list = [1, 2, 3, 4, 5]
5 | idx = 3
6 | new_list = delete_at(my_list, idx)
7 | print(new_list)
8 | print(my_list)
9 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/3-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | print_reversed_list_integer = __import__('3-print_reversed_list_integer').print_reversed_list_integer
3 |
4 | my_list = [1, 2, 3, 4, 5]
5 | print_reversed_list_integer(my_list)
6 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/3-print_reversed_list_integer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def print_reversed_list_integer(my_list=[]):
4 |
5 | if my_list:
6 | for i in reversed(my_list):
7 | print('{:d}'.format(i))
8 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/5-no_c.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def no_c(my_string):
4 | updated_str = ''
5 | for i in my_string:
6 | if i != 'c' and i != 'C':
7 | updated_str += i
8 | return (updated_str)
9 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/9-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | max_integer = __import__('9-max_integer').max_integer
3 |
4 | my_list = [1, 90, 2, 13, 34, 5, -13, 3]
5 | max_value = max_integer(my_list)
6 | print("Max: {}".format(max_value))
7 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/6-print_sorted_dictionary.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def print_sorted_dictionary(a_dictionary):
3 | for keys in sorted(a_dictionary.keys()):
4 | print('{}: {}'. format(keys, a_dictionary[keys]))
5 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/0-square_matrix_simple.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/0-square_matrix_simple.cpython-38.pyc
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/100-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | matrix_mul = __import__('100-matrix_mul').matrix_mul
3 |
4 | print(matrix_mul([[1, 2], [3, 4]], [[1, 2], [3, 4]]))
5 | print(matrix_mul([[1, 2]], [[3, 4], [5, 6]]))
6 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/__pycache__/101-lazy_matrix_mul.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x07-python-test_driven_development/__pycache__/101-lazy_matrix_mul.cpython-38.pyc
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/100-magic_string.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def magic_string():
3 | magic_string.count = getattr(magic_string, 'count', 0) + 1
4 | return ", ".join(["BestSchool" for i in range(magic_string.count)])
5 |
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/tests/test_models/__pycache__/test_base.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0C-python-almost_a_circle/tests/test_models/__pycache__/test_base.cpython-38.pyc
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/2-arguments.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const argc = process.argv.length;
3 |
4 | if (argc > 2) {
5 | console.log('Argument' + (argc > 3 ? 's' : '') + ' found');
6 | } else {
7 | console.log('No argument');
8 | }
9 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/__pycache__/3-print_reversed_list_integer.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x03-python-data_structures/__pycache__/3-print_reversed_list_integer.cpython-38.pyc
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/__pycache__/6-print_sorted_dictionary.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x04-python-more_data_structures/__pycache__/6-print_sorted_dictionary.cpython-38.pyc
--------------------------------------------------------------------------------
/0x05-python-exceptions/1-safe_print_integer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def safe_print_integer(value):
3 | try:
4 | print("{:d}".format(value))
5 | return True
6 | except (ValueError, TypeError):
7 | return False
8 |
--------------------------------------------------------------------------------
/0x08-python-more_classes/1-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Rectangle = __import__('1-rectangle').Rectangle
3 |
4 | rect = Rectangle(2, 4)
5 | print(rect.__dict__)
6 |
7 | rect.width = 10
8 | rect.height = 3
9 | print(rect.__dict__)
10 |
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/tests/test_models/__pycache__/test_square.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0C-python-almost_a_circle/tests/test_models/__pycache__/test_square.cpython-38.pyc
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/10-converter.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | exports.converter = function (base) {
4 | function myConverter (n) {
5 | return n.toString(base);
6 | }
7 |
8 | return myConverter;
9 | };
10 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/7-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $.getJSON(
3 | "https://swapi-api.alx-tools.com/api/people/5/?format=json",
4 | function (data) {
5 | $("DIV#character").text(data.name);
6 | }
7 | );
8 | });
9 |
--------------------------------------------------------------------------------
/0x0C-python-almost_a_circle/tests/test_models/__pycache__/test_rectangle.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Innocentsax/alx-higher_level_programming/HEAD/0x0C-python-almost_a_circle/tests/test_models/__pycache__/test_rectangle.cpython-38.pyc
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/1-create_user.sql:
--------------------------------------------------------------------------------
1 | -- creates the MySQL server user user_0d_1 and grant all priviledges
2 | CREATE USER IF NOT EXISTS user_0d_1@localhost IDENTIFIED BY 'user_0d_1_pwd';
3 | GRANT ALL PRIVILEGES ON * . * TO user_0d_1@localhost;
4 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/100-print_tebahpla.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | for i in range(ord('z'), ord('a') - 1, -1):
3 | if i % 2 == 0:
4 | diff = 0
5 | else:
6 | diff = 32
7 | print('{}'.format(chr(i - diff)), end='')
8 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/8-uppercase.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def uppercase(str):
3 | for i in str:
4 | if ord(i) >= 97 and ord(i) <= 122:
5 | i = chr(ord(i) - 32)
6 | print("{}".format(i), end="")
7 | print()
8 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/11-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | multiply_list_map = __import__('11-multiply_list_map').multiply_list_map
3 |
4 | my_list = [1, 2, 3, 4, 6]
5 | new_list = multiply_list_map(my_list, 4)
6 | print(new_list)
7 | print(my_list)
8 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/2-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | matrix_divided = __import__('2-matrix_divided').matrix_divided
3 |
4 | matrix = [
5 | [1, 2, 3],
6 | [4, 5, 6]
7 | ]
8 | print(matrix_divided(matrix, 3))
9 | print(matrix)
10 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/8-multiple_returns.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def multiple_returns(sentence):
4 | if sentence != '':
5 | first_char = sentence[0]
6 | else:
7 | first_char = None
8 | return (len(sentence), first_char)
9 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/1-search_replace.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def search_replace(my_list, search, replace):
3 | def find_search(element):
4 | return element if element != search else replace
5 | return list(map(find_search, my_list))
6 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/search_replace.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def search_replace(my_list, search, replace):
3 | def find_search(element):
4 | return element if element != search else replace
5 | return list(map(find_search, my_list))
6 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/101-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | lazy_matrix_mul = __import__('101-lazy_matrix_mul').lazy_matrix_mul
3 |
4 | print(lazy_matrix_mul([[1, 2], [3, 4]], [[1, 2], [3, 4]]))
5 | print(lazy_matrix_mul([[1, 2]], [[3, 4], [5, 6]]))
6 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/0-lookup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines an object attribute and methods using lookup function."""
3 |
4 |
5 | def lookup(obj):
6 | """Return a list of an object's available attributes and methods."""
7 | return (dir(obj))
8 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/3-to_json_string.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Writes a string-to-JSON function."""
3 | import json
4 |
5 |
6 | def to_json_string(my_obj):
7 | """Return the JSON representation of a string object."""
8 | return json.dumps(my_obj)
9 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/8-class_to_json.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Module Defines a Python class-to-JSON function."""
3 |
4 |
5 | def class_to_json(obj):
6 | """Return the dictionary represntation of a simple data structure."""
7 | return obj.__dict__
8 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/101-avg_temperatures.sql:
--------------------------------------------------------------------------------
1 | -- Displays the average temperature (in Fahrenheit) by city ordered by descending temperature.
2 | SELECT `city`, AVG(`value`) AS `avg_temp`
3 | FROM `temperatures`
4 | GROUP BY `city`
5 | ORDER BY `avg_temp` DESC;
6 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/6-print_comb3.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | for x in range(0, 10):
3 | for y in range(x + 1, 10):
4 | if x == 8 and y == 9:
5 | print('89')
6 | else:
7 | print('{}{}, '.format(x, y), end='')
8 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/8-concat_edges.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | str = "Python is an interpreted, interactive, object-oriented programming\
3 | language that combines remarkable power with very clear syntax"
4 | str = str[39:67] + str[-22:-17] + str[0:6]
5 | print(str)
6 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/2-replace_in_list.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def replace_in_list(my_list, idx, element):
4 | if idx < 0 or idx >= len(my_list):
5 | return (my_list)
6 | else:
7 | my_list[idx] = element
8 | return (my_list)
9 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/1-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | search_replace = __import__('1-search_replace').search_replace
3 |
4 | my_list = [1, 2, 3, 4, 5, 4, 2, 1, 1, 4, 89]
5 | new_list = search_replace(my_list, 2, 89)
6 |
7 | print(new_list)
8 | print(my_list)
9 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/16-no_link.sql:
--------------------------------------------------------------------------------
1 | -- Lists all records of the table second_table having a name value in my MySQL server.
2 | -- Records are ordered by descending score.
3 | SELECT `score`, `name`
4 | FROM `second_table`
5 | WHERE `name` != ""
6 | ORDER BY `score` DESC
7 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/7-multi_c.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const x = process.argv[2];
3 |
4 | if (!parseInt(x)) {
5 | console.log('Missing number of occurrences');
6 | } else {
7 | for (let i = 0; i < x; i++) {
8 | console.log('C is fun');
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/add_0.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def add(a, b):
3 | """My addition function
4 | Args:
5 | a: first integer
6 | b: second integer
7 | Returns:
8 | The return value. a + b
9 | """
10 | return (a + b)
11 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/11-best_score.sql:
--------------------------------------------------------------------------------
1 | -- Lists all records in the table second_table with a score >= 10 in my MySQL server.
2 | -- Records are ordered by descending score.
3 | SELECT `score`, `name`
4 | FROM `second_table`
5 | WHERE `score` >= 10
6 | ORDER BY `score` DESC;
7 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/5-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | number_keys = __import__('5-number_keys').number_keys
3 |
4 | a_dictionary = { 'language': "C", 'number': 13, 'track': "Low level" }
5 | nb_keys = number_keys(a_dictionary)
6 | print("Number of keys: {:d}".format(nb_keys))
7 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/7-edges.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | word = "Holberton"
3 | word_first_3 = word[0:3]
4 | word_last_2 = word[-2:]
5 | middle_word = word[1:-1]
6 | print(f"First 3 letters: {word_first_3}")
7 | print(f"Last 2 letters: {word_last_2}")
8 | print(f"Middle word: {middle_word}")
9 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/4-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | new_in_list = __import__('4-new_in_list').new_in_list
3 |
4 | my_list = [1, 2, 3, 4, 5]
5 | idx = 3
6 | new_element = 9
7 | new_list = new_in_list(my_list, idx, new_element)
8 |
9 | print(new_list)
10 | print(my_list)
11 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/8-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | multiple_returns = __import__('8-multiple_returns').multiple_returns
3 |
4 | sentence = "At school, I learnt C!"
5 | length, first = multiple_returns(sentence)
6 | print("Length: {:d} - First character: {}".format(length, first))
7 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/101-safe_function.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | import sys
3 |
4 |
5 | def safe_function(fct, *args):
6 | try:
7 | return fct(*args)
8 | except Exception as e:
9 | print("Exception: {}".format(e), file=sys.stderr)
10 | return None
11 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/15-groups.sql:
--------------------------------------------------------------------------------
1 | -- Lists the number of records with the same score in the table second_table in my MySQL server.
2 | -- Records are ordered by descending count.
3 | SELECT `score`, COUNT(*) AS `number`
4 | FROM `second_table`
5 | GROUP BY `score`
6 | ORDER BY `number` DESC;
7 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/9-cities_by_state_join.sql:
--------------------------------------------------------------------------------
1 | -- lists all cities contained in the database hbtn_0d_usa
2 | -- lists all rows of a particular column in a database
3 | SELECT cities.id, cities.name, states.name FROM cities LEFT JOIN states ON states.id = cities.state_id ORDER BY cities.id;
4 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/8-esrever.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | exports.esrever = function (list) {
4 | const reversedList = [];
5 | for (let i = list.length - 1; i >= 0; i--) {
6 | reversedList.push(list[i]);
7 | }
8 |
9 | return (reversedList);
10 | };
11 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/3-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | common_elements = __import__('3-common_elements').common_elements
3 |
4 | set_1 = { "Python", "C", "Javascript" }
5 | set_2 = { "Bash", "C", "Ruby", "Perl" }
6 | c_set = common_elements(set_1, set_2)
7 | print(sorted(list(c_set)))
8 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/6-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | print_sorted_dictionary = __import__('6-print_sorted_dictionary').print_sorted_dictionary
3 |
4 | a_dictionary = { 'language': "C", 'Number': 89, 'track': "Low level", 'ids': [1, 2, 3] }
5 | print_sorted_dictionary(a_dictionary)
6 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/102-top_city.sql:
--------------------------------------------------------------------------------
1 | -- Displays the 3 cities with the highest average temperatures between July and August.
2 | SELECT `city`, AVG(`value`) AS `avg_temp`
3 | FROM `temperatures`
4 | WHERE `month` = 7 OR `month` = 8
5 | GROUP BY `city`
6 | ORDER BY `avg_temp` DESC
7 | LIMIT 3;
8 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/0-positive_or_negative.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | import random
3 | number = random.randint(-10, 10)
4 | if number > 0:
5 | print(f"{number} is positive")
6 | elif number == 0:
7 | print(f"{number} is zero")
8 | else:
9 | print(f"{number} is negative")
10 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/2-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | replace_in_list = __import__('2-replace_in_list').replace_in_list
3 |
4 | my_list = [1, 2, 3, 4, 5]
5 | idx = 3
6 | new_element = 9
7 | new_list = replace_in_list(my_list, idx, new_element)
8 |
9 | print(new_list)
10 | print(my_list)
11 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/1-writeme.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const fs = require('fs');
4 | const filename = process.argv[2];
5 | const content = process.argv[3];
6 |
7 | fs.writeFile(filename, content, 'utf-8', (error) => {
8 | if (error) {
9 | console.log(error);
10 | }
11 | });
12 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/7-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | add_tuple = __import__('7-add_tuple').add_tuple
3 |
4 | tuple_a = (1, 89)
5 | tuple_b = (88, 11)
6 | new_tuple = add_tuple(tuple_a, tuple_b)
7 | print(new_tuple)
8 |
9 | print(add_tuple(tuple_a, (1, )))
10 | print(add_tuple(tuple_a, ()))
11 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/4-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | only_diff_elements = __import__('4-only_diff_elements').only_diff_elements
3 |
4 | set_1 = { "Python", "C", "Javascript" }
5 | set_2 = { "Bash", "C", "Ruby", "Perl" }
6 | od_set = only_diff_elements(set_1, set_2)
7 | print(sorted(list(od_set)))
8 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/2-append_write.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Writes a file-appending function."""
3 |
4 |
5 | def append_write(filename="", text=""):
6 | """Appends a string to the end of a UTF8 text file"""
7 | with open(filename, "a", encoding="utf-8") as f:
8 | return f.write(text)
9 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/4-from_json_string.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # 6-from_json_string.py
3 | """Writes a JSON-to-object function."""
4 | import json
5 |
6 |
7 | def from_json_string(my_str):
8 | """Return the Python object representation of a JSON string."""
9 | return json.loads(my_str)
10 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/8-cities_of_california_subquery.sql:
--------------------------------------------------------------------------------
1 | -- lists all the cities of California that can be found in the database hbtn_0d_usa
2 | -- lists all rows of a column in a database
3 | SELECT id, name FROM cities WHERE state_id = (SELECT id FROM states WHERE name = 'California') ORDER BY id ASC;
4 |
5 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/11-second_biggest.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | if (process.argv.length <= 3) {
3 | console.log(0);
4 | } else {
5 | const args = process.argv
6 | .map(Number)
7 | .slice(2, process.argv.length)
8 | .sort((a, b) => a - b);
9 | console.log(args[args.length - 2]);
10 | }
11 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/1-rectangle.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | /**
3 | * Represents a rectangle class with width and height attributes
4 | */
5 | class Rectangle {
6 | constructor (w, h) {
7 | this.width = w;
8 | this.height = h;
9 | }
10 | }
11 | module.exports = Rectangle;
12 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/0-readme.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const fs = require('fs');
4 | const filename = process.argv[2];
5 |
6 | fs.readFile(filename, 'utf-8', (error, content) => {
7 | if (error) {
8 | console.log(error);
9 | } else {
10 | console.log(content);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/4-hidden_discovery.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | if __name__ == "__main__":
4 | """Print all names defined by hidden_4 module."""
5 | import hidden_4
6 |
7 | names = dir(hidden_4)
8 | for name in names:
9 | if name[:2] != "__":
10 | print(name)
11 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/6-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | print_matrix_integer = __import__('6-print_matrix_integer').print_matrix_integer
3 |
4 | matrix = [
5 | [1, 2, 3],
6 | [4, 5, 6],
7 | [7, 8, 9]
8 | ]
9 |
10 | print_matrix_integer(matrix)
11 | print("--")
12 | print_matrix_integer()
13 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/3-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | say_my_name = __import__('3-say_my_name').say_my_name
3 |
4 | say_my_name("John", "Smith")
5 | say_my_name("Walter", "White")
6 | say_my_name("Bob")
7 | try:
8 | say_my_name(12, "White")
9 | except Exception as e:
10 | print(e)
11 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/3-infinite_add.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | if __name__ == "__main__":
4 | """Print the addition of all arguments."""
5 | import sys
6 |
7 | total = 0
8 | for i in range(len(sys.argv) - 1):
9 | total += int(sys.argv[i + 1])
10 | print("{}".format(total))
11 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/10-divisible_by_2.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def divisible_by_2(my_list=[]):
4 | new_list = []
5 |
6 | for i in my_list:
7 | if i % 2 == 0:
8 | new_list.append(True)
9 | else:
10 | new_list.append(False)
11 | return (new_list)
12 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/6-base_geometry.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a base geometry class BaseGeometry."""
3 |
4 |
5 | class BaseGeometry:
6 | """Represent base geometry."""
7 |
8 | def area(self):
9 | """Not implemented."""
10 | raise Exception("area() is not implemented")
11 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/6-load_from_json_file.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Module defines a JSON file-reading function"""
3 | import json
4 |
5 |
6 | def load_from_json_file(filename):
7 | """Creates a Python object from a given JSON file"""
8 | with open(filename) as f:
9 | return json.load(f)
10 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/7-occurrences.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | exports.nbOccurences = function (list, searchElement) {
4 | let count = 0;
5 |
6 | for (let i = 0; i < list.length; i++) {
7 | count = (list[i] === searchElement ? count + 1 : count);
8 | }
9 |
10 | return count;
11 | };
12 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/2-statuscode.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const request = require('request');
3 | const url = process.argv[2];
4 |
5 | request.get(url, (error, response) => {
6 | if (error) {
7 | console.log(error);
8 | } else {
9 | console.log(`code: ${response.statusCode}`);
10 | }
11 | });
12 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/8-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $.getJSON(
3 | "https://swapi-api.alx-tools.com/api/films/?format=json",
4 | function (data) {
5 | data.results.forEach(function (film) {
6 | $("").text(film.title).appendTo("ul#list_movies");
7 | });
8 | }
9 | );
10 | });
11 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/0-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | square_matrix_simple = __import__('0-square_matrix_simple').square_matrix_simple
3 |
4 | matrix = [
5 | [1, 2, 3],
6 | [4, 5, 6],
7 | [7, 8, 9]
8 | ]
9 |
10 | new_matrix = square_matrix_simple(matrix)
11 | print(new_matrix)
12 | print(matrix)
13 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/0-read_file.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Write a function that reads a text file (UTF8) and prints it to stdout."""
3 |
4 |
5 | def read_file(filename=""):
6 | """Print the contents of a UTF8 text file to stdout."""
7 | with open(filename, encoding="utf-8") as f:
8 | print(f.read(), end="")
9 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/100-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | weight_average = __import__('100-weight_average').weight_average
3 |
4 | my_list = [(1, 2), (2, 1), (3, 10), (4, 2)]
5 | # = ((1 * 2) + (2 * 1) + (3 * 10) + (4 * 2)) / (2 + 1 + 10 + 2)
6 | result = weight_average(my_list)
7 | print("Average: {:0.2f}".format(result))
8 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/101-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | square_matrix_map = \
3 | __import__('101-square_matrix_map').square_matrix_map
4 |
5 | matrix = [
6 | [1, 2, 3],
7 | [4, 5, 6],
8 | [7, 8, 9]
9 | ]
10 |
11 | new_matrix = square_matrix_map(matrix)
12 | print(new_matrix)
13 | print(matrix)
14 |
--------------------------------------------------------------------------------
/0x06-python-classes/5-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Square = __import__('5-square').Square
3 |
4 | my_square = Square(3)
5 | my_square.my_print()
6 |
7 | print("--")
8 |
9 | my_square.size = 10
10 | my_square.my_print()
11 |
12 | print("--")
13 |
14 | my_square.size = 0
15 | my_square.my_print()
16 |
17 | print("--")
18 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/5-save_to_json_file.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Writes a JSON file-writing function."""
3 | import json
4 |
5 |
6 | def save_to_json_file(my_obj, filename):
7 | """Write an object to a text file using JSON representation."""
8 | with open(filename, "w") as f:
9 | json.dump(my_obj, f)
10 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/9-print_last_digit.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def print_last_digit(number):
3 | if number < 0:
4 | last_digit = number % -(10)
5 | print(-(last_digit), end='')
6 | else:
7 | last_digit = number % 10
8 | print(last_digit, end='')
9 | return abs(last_digit)
10 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/101-locked_class.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a locked class."""
3 |
4 |
5 | class LockedClass:
6 | """
7 | Prevent the user from instantiating new LockedClass attributes
8 | for anything but attributes called 'first_name'.
9 | """
10 |
11 | __slots__ = ["first_name"]
12 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/5-square.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | /**
3 | * Square class that inherits from rectangle class
4 | */
5 | const Rectangle = require('./4-rectangle');
6 |
7 | class Square extends Rectangle {
8 | constructor (size) {
9 | super(size, size);
10 | }
11 | }
12 |
13 | module.exports = Square;
14 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/0-safe_print_list.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def safe_print_list(my_list=[], x=0):
4 | total = 0
5 | for i in range(x):
6 | try:
7 | print(f"{my_list[i]}", end="")
8 | total += 1
9 | except IndexError:
10 | break
11 | print()
12 | return(total)
13 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/1-my_list.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines an subclass or child list class MyList."""
3 |
4 |
5 | class MyList(list):
6 | """These class is a subclass of the list class."""
7 |
8 | def print_sorted(self):
9 | """Print a sorted list in a specific pattern."""
10 | print(sorted(self))
11 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/2-is_same_class.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a class-checking function."""
3 |
4 |
5 | def is_same_class(obj, a_class):
6 | """Checks if object is an instance of a class,
7 | Return true if object is an instance of the
8 | class, otherwise return false"""
9 | return (type(obj) == a_class)
10 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/4-new_in_list.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def new_in_list(my_list, idx, element):
4 | if my_list:
5 | if idx < 0 or idx >= len(my_list):
6 | return my_list
7 | else:
8 | new_list = my_list.copy()
9 | new_list[idx] = element
10 | return new_list
11 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/100-weight_average.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def weight_average(my_list=[]):
3 | if my_list and len(my_list):
4 | num = 0
5 | denom = 0
6 | for tup in my_list:
7 | num += (tup[0] * tup[1])
8 | denom += (tup[1])
9 | return (num/denom)
10 | return 0
11 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/3-safe_print_division.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def safe_print_division(a, b):
3 | """Returns the division of a by b."""
4 | try:
5 | div = a / b
6 | except (TypeError, ZeroDivisionError):
7 | div = None
8 | finally:
9 | print("Inside result: {}".format(div))
10 | return (div)
11 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/102-rating_shows.sql:
--------------------------------------------------------------------------------
1 | -- lists all shows from hbtn_0d_tvshows_rate by their rating
2 | -- lists all rows of a table by the sum of a linked row
3 | SELECT title, SUM(tv_show_ratings.rate) 'rating'
4 | FROM tv_shows
5 | LEFT JOIN tv_show_ratings ON tv_show_ratings.show_id = tv_shows.id
6 | GROUP BY title
7 | ORDER BY rating DESC;
8 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/11-genre_id_all_shows.sql:
--------------------------------------------------------------------------------
1 | -- lists all shows contained in the database hbtn_0d_tvshows
2 | -- lists all rows of tables in a database
3 | SELECT tv_shows.title, tv_show_genres.genre_id
4 | FROM tv_shows LEFT JOIN tv_show_genres
5 | ON tv_shows.id = tv_show_genres.show_id
6 | ORDER BY tv_shows.title ASC, tv_show_genres.genre_id ASC;
7 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/README.md:
--------------------------------------------------------------------------------
1 | ## 0x00-python-hello_world tasks & their solutions
2 | ___
3 | [](https://github.com/Innocentsax/standard-readme)
4 | + This directory contains solutions that I submitted for the tasks on 0x00-python-hello_world.
5 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/102-complex_delete.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def complex_delete(a_dictionary, value):
3 | keys_to_del = []
4 | for key in a_dictionary:
5 | if a_dictionary[key] == value:
6 | keys_to_del.append(key)
7 | for key in keys_to_del:
8 | del a_dictionary[key]
9 | return a_dictionary
10 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/9-max_integer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def max_integer(my_list=[]):
4 | if len(my_list) == 0:
5 | return (None)
6 | else:
7 | max_int = my_list[0]
8 | for i in range(len(my_list)):
9 | if my_list[i] > max_int:
10 | max_int = my_list[i]
11 | return (max_int)
12 |
--------------------------------------------------------------------------------
/0x06-python-classes/6-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Square = __import__('6-square').Square
3 |
4 | my_square_1 = Square(3)
5 | my_square_1.my_print()
6 |
7 | print("--")
8 |
9 | my_square_2 = Square(3, (1, 1))
10 | my_square_2.my_print()
11 |
12 | print("--")
13 |
14 | my_square_3 = Square(3, (3, 0))
15 | my_square_3.my_print()
16 |
17 | print("--")
18 |
--------------------------------------------------------------------------------
/0x08-python-more_classes/2-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Rectangle = __import__('2-rectangle').Rectangle
3 |
4 | rect = Rectangle(2, 4)
5 | print("Area: {} - Perimeter: {}".format(rect.area(), rect.perimeter()))
6 |
7 | print("--")
8 |
9 | rect.width = 10
10 | rect.height = 3
11 | print("Area: {} - Perimeter: {}".format(rect.area(), rect.perimeter()))
12 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/101-add_attribute.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a function that adds attributes to objects"""
3 |
4 |
5 | def add_attribute(obj, att, value):
6 | """Add a new attribute to an object."""
7 |
8 | if not hasattr(obj, "__dict__"):
9 | raise TypeError("can't add new attribute")
10 | setattr(obj, att, value)
11 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/100-safe_print_integer_err.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | import sys
3 |
4 |
5 | def safe_print_integer_err(value):
6 | try:
7 | print("{:d}".format(value))
8 | return (True)
9 | except (TypeError, ValueError):
10 | print("Exception: {}".format(sys.exc_info()[1]), file=sys.stderr)
11 | return (False)
12 |
--------------------------------------------------------------------------------
/0x06-python-classes/1-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Square = __import__('1-square').Square
3 |
4 | my_square = Square(3)
5 | print(type(my_square))
6 | print(my_square.__dict__)
7 |
8 | try:
9 | print(my_square.size)
10 | except Exception as e:
11 | print(e)
12 |
13 | try:
14 | print(my_square.__size)
15 | except Exception as e:
16 | print(e)
17 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/2-create_read_user.sql:
--------------------------------------------------------------------------------
1 | -- creates the database hbtn_0d_2 and the user user_0d_2
2 | -- creates a database
3 | CREATE DATABASE IF NOT EXISTS hbtn_0d_2;
4 | -- creates a user
5 | CREATE USER IF NOT EXISTS user_0d_2@localhost IDENTIFIED BY 'user_0d_2_pwd';
6 | -- grants SELECT privileges to a user
7 | GRANT SELECT ON hbtn_0d_2.* TO user_0d_2@localhost;
8 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/101-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $("#add_item").click(function () {
3 | $("").text("Item").appendTo("ul.my_list");
4 | });
5 | $("#remove_item").click(function () {
6 | $("ul.my_list li:last-child").remove();
7 | });
8 | $("#clear_list").click(function () {
9 | $("ul.my_list").empty();
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/3-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | safe_print_division = __import__('3-safe_print_division').safe_print_division
3 |
4 | a = 12
5 | b = 2
6 | result = safe_print_division(a, b)
7 | print("{:d} / {:d} = {}".format(a, b, result))
8 |
9 | a = 12
10 | b = 0
11 | result = safe_print_division(a, b)
12 | print("{:d} / {:d} = {}".format(a, b, result))
13 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/4-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | print_square = __import__('4-print_square').print_square
3 |
4 | print_square(4)
5 | print("")
6 | print_square(10)
7 | print("")
8 | print_square(0)
9 | print("")
10 | print_square(1)
11 | print("")
12 | try:
13 | print_square(-1)
14 | except Exception as e:
15 | print(e)
16 | print("")
17 |
--------------------------------------------------------------------------------
/0x11-python-network_1/4-hbtn_status.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Fetches https://alx-intranet.hbtn.io/status."""
3 | import requests
4 |
5 |
6 | if __name__ == "__main__":
7 | r = requests.get("https://alx-intranet.hbtn.io/status")
8 | print("Body response:")
9 | print("\t- type: {}".format(type(r.text)))
10 | print("\t- content: {}".format(r.text))
11 |
--------------------------------------------------------------------------------
/0x11-python-network_1/5-hbtn_header.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Displays the X-Request-Id header variable of a request to a given URL.
3 | Usage: ./5-hbtn_header.py
4 | """
5 | import sys
6 | import requests
7 |
8 |
9 | if __name__ == "__main__":
10 | url = sys.argv[1]
11 |
12 | r = requests.get(url)
13 | print(r.headers.get("X-Request-Id"))
14 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/2-rectangle.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | /**
3 | * Check the parameters provided
4 | */
5 | class Rectangle {
6 | constructor (w, h) {
7 | if (typeof w === 'number' && w > 0 && typeof h === 'number' && h > 0) {
8 | this.width = w;
9 | this.height = h;
10 | }
11 | }
12 | }
13 | module.exports = Rectangle;
14 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/10-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | divisible_by_2 = __import__('10-divisible_by_2').divisible_by_2
3 |
4 | my_list = [0, 1, 2, 3, 4, 5, 6]
5 | list_result = divisible_by_2(my_list)
6 |
7 | i = 0
8 | while i < len(list_result):
9 | print("{:d} {:s} divisible by 2".format(my_list[i], "is" if list_result[i] else "is not"))
10 | i += 1
11 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/6-print_matrix_integer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def print_matrix_integer(matrix=[[]]):
4 | for row in matrix:
5 | for column in row:
6 | if column == row[-1]:
7 | print('{:d}'.format(column), end='')
8 | else:
9 | print('{:d}'.format(column), end=' ')
10 | print()
11 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/10-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | best_score = __import__('10-best_score').best_score
3 |
4 | a_dictionary = {'John': 12, 'Bob': 14, 'Mike': 14, 'Molly': 16, 'Adam': 10}
5 | best_key = best_score(a_dictionary)
6 | print("Best score: {}".format(best_key))
7 |
8 | best_key = best_score(None)
9 | print("Best score: {}".format(best_key))
10 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/2-safe_print_list_integers.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def safe_print_list_integers(my_list=[], x=0):
3 | count = 0
4 | for i in range(x):
5 | try:
6 | print("{:d}".format(my_list[i]), end="")
7 | count += 1
8 | except (ValueError, TypeError):
9 | pass
10 | print()
11 | return (count)
12 |
--------------------------------------------------------------------------------
/0x08-python-more_classes/3-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Rectangle = __import__('3-rectangle').Rectangle
3 |
4 | rect = Rectangle(2, 4)
5 | print("Area: {} - Perimeter: {}".format(rect.area(), rect.perimeter()))
6 |
7 | print(str(rect))
8 | print(repr(rect))
9 |
10 | print("--")
11 |
12 | rect.width = 10
13 | rect.height = 3
14 | print(rect)
15 | print(repr(rect))
16 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/8-square.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const x = process.argv[2];
3 |
4 | if (!parseInt(x)) {
5 | console.log('Missing size');
6 | } else {
7 | for (let i = 0; i < x; i++) {
8 | let y = 0;
9 | let myVar = '';
10 |
11 | while (y < x) {
12 | myVar = myVar + 'X';
13 | y++;
14 | }
15 | console.log(myVar);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/102-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $("INPUT#btn_translate").click(function () {
3 | const language_code = $("INPUT#language_code").val();
4 | $.getJSON(
5 | `https://fourtonfish.com/hellosalut/hello/?lang=${language_code}`,
6 | function (data) {
7 | $("#hello").text(data.hello);
8 | }
9 | );
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/10-genre_id_by_show.sql:
--------------------------------------------------------------------------------
1 | -- lists all shows contained in hbtn_0d_tvshows that have at least one genre linked
2 | -- lists all rows of a database that have one column in common
3 | SELECT tv_shows.title, tv_show_genres.genre_id FROM tv_shows INNER JOIN tv_show_genres ON tv_shows.id = tv_show_genres.show_id ORDER BY tv_shows.title ASC, tv_show_genres.genre_id ASC;
4 |
--------------------------------------------------------------------------------
/0x12-javascript-warm_up/103-object_fct.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const myObject = {
3 | type: 'object',
4 | value: 12
5 | };
6 | console.log(myObject);
7 |
8 | myObject.incr = function () {
9 | this.value++;
10 | };
11 |
12 | myObject.incr();
13 | console.log(myObject);
14 | myObject.incr();
15 | console.log(myObject);
16 | myObject.incr();
17 | console.log(myObject);
18 |
--------------------------------------------------------------------------------
/0x06-python-classes/1-square.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # 0-square.py by UDO INNOCENT
3 | """Defines a square """
4 |
5 |
6 | class Square:
7 | """Represents a square"""
8 |
9 | def __init__(self, size):
10 | """Initializing this square class
11 | Args: size - represnets the size of the square defined
12 | """
13 |
14 | self.__size = size
15 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/102-magic_calculation.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def magic_calculation(a, b):
4 | """Match bytecode provided"""
5 | from magic_calculation_102 import add, sub
6 |
7 | if a < b:
8 | c = add(a, b)
9 | for i in range(4, 6):
10 | c = add(c, i)
11 | return (c)
12 |
13 | else:
14 | return (sub(a, b))
15 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/3-is_kind_of_class.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a class and inherited class-checking function."""
3 |
4 |
5 | def is_kind_of_class(obj, a_class):
6 | """returns true if object is an instance of a class
7 | or a class that the class in question inherits from"""
8 | if isinstance(obj, a_class):
9 | return True
10 | return False
11 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/16-shows_by_genre.sql:
--------------------------------------------------------------------------------
1 | -- lists all shows, and all genres linked to that show, from the database hbtn_0d_tvshows
2 | -- lists all rows of a table linked to another table
3 | SELECT title, name
4 | FROM tv_shows
5 | LEFT JOIN tv_show_genres ON tv_shows.id = tv_show_genres.show_id
6 | LEFT JOIN tv_genres ON tv_show_genres.genre_id = tv_genres.id
7 | ORDER BY title ASC, name ASC;
8 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/12-no_genre.sql:
--------------------------------------------------------------------------------
1 | -- lists all shows contained in hbtn_0d_tvshows without a genre linked
2 | -- lists all rows of a database that don't have one column
3 | SELECT tv_shows.title, tv_show_genres.genre_id
4 | FROM tv_shows LEFT JOIN tv_show_genres
5 | ON tv_shows.id = tv_show_genres.show_id
6 | WHERE tv_show_genres.genre_id IS NULL
7 | ORDER BY tv_shows.title ASC, tv_show_genres.genre_id ASC;
8 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/6-states.sql:
--------------------------------------------------------------------------------
1 | -- creates the database hbtn_0d_usa and the table states (in the database hbtn_0d_usa) on your MySQL server
2 | -- creates a database
3 | CREATE DATABASE IF NOT EXISTS hbtn_0d_usa;
4 | -- use a database
5 | USE hbtn_0d_usa;
6 | -- creates a table
7 | CREATE TABLE IF NOT EXISTS states (id INT UNIQUE NOT NULL AUTO_INCREMENT, name VARCHAR(256) NOT NULL, PRIMARY KEY(id));
8 |
9 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/102-magic_calculation.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def magic_calculation(a, b):
3 | result = 0
4 | for i in range(1, 3):
5 | try:
6 | if i > a:
7 | raise Exception('Too far')
8 | else:
9 | result += (a ** b) / i
10 | except Exception:
11 | result = b + a
12 | break
13 | return (result)
14 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/13-count_shows_by_genre.sql:
--------------------------------------------------------------------------------
1 | -- lists all genres from hbtn_0d_tvshows and displays the number of shows linked to each
2 | -- lists all rows of a database meeting a condition
3 | SELECT tv_genres.name AS 'genre', COUNT(tv_show_genres.genre_id) AS 'number_of_shows'
4 | FROM tv_genres RIGHT JOIN tv_show_genres
5 | ON tv_genres.id = tv_show_genres.genre_id
6 | GROUP BY genre
7 | ORDER BY number_of_shows DESC;
8 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/15-comedy_only.sql:
--------------------------------------------------------------------------------
1 | -- lists all Comedy shows in the database hbtn_0d_tvshows
2 | -- lists all rows of a database corresponding to a column value
3 | SELECT title
4 | FROM tv_shows
5 | LEFT JOIN tv_show_genres ON tv_shows.id = tv_show_genres.show_id
6 | LEFT JOIN tv_genres ON tv_show_genres.genre_id = tv_genres.id
7 | WHERE tv_genres.name = 'Comedy'
8 | GROUP BY title
9 | ORDER BY title ASC;
10 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/1-calculation.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | if __name__ == "__main__":
3 | from calculator_1 import add, sub, mul, div
4 |
5 | a = 10
6 | b = 5
7 | print('{:d} + {:d} = {:d}'.format(a, b, (add(a, b))))
8 | print('{:d} - {:d} = {:d}'.format(a, b, (sub(a, b))))
9 | print('{:d} * {:d} = {:d}'.format(a, b, (mul(a, b))))
10 | print('{:d} / {:d} = {:d}'.format(a, b, (div(a, b))))
11 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/101-sorted.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const dict = require('./101-data.js').dict;
3 |
4 | const newDict = {};
5 |
6 | Object.getOwnPropertyNames(dict).forEach(occurences => {
7 | if (newDict[dict[occurences]] === undefined) {
8 | newDict[dict[occurences]] = [occurences];
9 | } else {
10 | newDict[dict[occurences]].push(occurences);
11 | }
12 | });
13 | console.log(newDict);
14 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/3-starwars_title.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const request = require('request');
4 | const movieId = process.argv[2];
5 | const url = `https://swapi-api.alx-tools.com/api/films/${movieId}`;
6 |
7 | request.get(url, (error, response, body) => {
8 | if (error) {
9 | console.log(error);
10 | } else {
11 | const data = JSON.parse(body);
12 | console.log(data.title);
13 | }
14 | });
15 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/0-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | add_integer = __import__('0-add_integer').add_integer
3 |
4 | print(add_integer(1, 2))
5 | print(add_integer(100, -2))
6 | print(add_integer(2))
7 | print(add_integer(100.3, -2))
8 | try:
9 | print(add_integer(4, "School"))
10 | except Exception as e:
11 | print(e)
12 | try:
13 | print(add_integer(None))
14 | except Exception as e:
15 | print(e)
16 |
--------------------------------------------------------------------------------
/0x11-python-network_1/6-post_email.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Sends a POST request to a given URL with a given email.
3 | Usage: ./6-post_email.py
4 | - Displays the body of the response.
5 | """
6 | import sys
7 | import requests
8 |
9 |
10 | if __name__ == "__main__":
11 | url = sys.argv[1]
12 | value = {"email": sys.argv[2]}
13 |
14 | r = requests.post(url, data=value)
15 | print(r.text)
16 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/12-fizzbuzz.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def fizzbuzz():
3 | for number in range(1, 101):
4 | if number % 3 == 0 and number % 5 == 0:
5 | print("FizzBuzz ", end="")
6 | elif number % 3 == 0:
7 | print("Fizz ", end="")
8 | elif number % 5 == 0:
9 | print("Buzz ", end="")
10 | else:
11 | print("{} ".format(number), end="")
12 |
--------------------------------------------------------------------------------
/0x06-python-classes/3-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Square = __import__('3-square').Square
3 |
4 | my_square_1 = Square(3)
5 | print("Area: {}".format(my_square_1.area()))
6 |
7 | try:
8 | print(my_square_1.size)
9 | except Exception as e:
10 | print(e)
11 |
12 | try:
13 | print(my_square_1.__size)
14 | except Exception as e:
15 | print(e)
16 |
17 | my_square_2 = Square(5)
18 | print("Area: {}".format(my_square_2.area()))
19 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/103-rating_genres.sql:
--------------------------------------------------------------------------------
1 | -- lists all genres in the database hbtn_0d_tvshows_rate by their rating
2 | -- lists all rows in a database linked to a row in another table
3 | SELECT name, SUM(tv_show_ratings.rate) 'rating'
4 | FROM tv_genres
5 | INNER JOIN tv_show_genres ON tv_genres.id = tv_show_genres.genre_id
6 | INNER JOIN tv_show_ratings ON tv_show_genres.show_id = tv_show_ratings.show_id
7 | GROUP BY name
8 | ORDER BY rating DESC;
9 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/14-my_genres.sql:
--------------------------------------------------------------------------------
1 | -- uses the hbtn_0d_tvshows database to lists all genres of the show Dexter
2 | -- uses a databse to lists all rows in a table corresponding to all rows in another
3 | SELECT name
4 | FROM tv_genres
5 | LEFT JOIN tv_show_genres ON tv_genres.id = tv_show_genres.genre_id
6 | LEFT JOIN tv_shows ON tv_show_genres.show_id = tv_shows.id
7 | WHERE tv_shows.title = 'Dexter'
8 | GROUP BY name
9 | ORDER BY name ASC;
10 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/9-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | multiply_by_2 = __import__('9-multiply_by_2').multiply_by_2
3 | print_sorted_dictionary = \
4 | __import__('6-print_sorted_dictionary').print_sorted_dictionary
5 |
6 | a_dictionary = {'John': 12, 'Alex': 8, 'Bob': 14, 'Mike': 14, 'Molly': 16}
7 | new_dict = multiply_by_2(a_dictionary)
8 | print_sorted_dictionary(a_dictionary)
9 | print("--")
10 | print_sorted_dictionary(new_dict)
11 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/0-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | safe_print_list = __import__('0-safe_print_list').safe_print_list
3 |
4 | my_list = [1, 2, 3, 4, 5]
5 |
6 | nb_print = safe_print_list(my_list, 2)
7 | print("nb_print: {:d}".format(nb_print))
8 | nb_print = safe_print_list(my_list, len(my_list))
9 | print("nb_print: {:d}".format(nb_print))
10 | nb_print = safe_print_list(my_list, len(my_list) + 2)
11 | print("nb_print: {:d}".format(nb_print))
12 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/100-my_int.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Write a class MyInt that inherits from int."""
3 |
4 |
5 | class MyInt(int):
6 | """Invert int operators == and !=."""
7 |
8 | def __eq__(self, value):
9 | """Replace == opeartor with != behavior."""
10 | return self.real != value
11 |
12 | def __ne__(self, value):
13 | """Replace != operator with == behavior."""
14 | return self.real == value
15 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/12-roman_to_int.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 |
4 | def roman_to_int(roman_string):
5 | if not roman_string or type(roman_string) != str:
6 | return 0
7 | total = 0
8 | digits = {'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10, 'V': 5, 'I': 1}
9 | for roman in reversed(roman_string):
10 | arabic = digits[roman]
11 | total += arabic if total < arabic * 5 else -arabic
12 | return total
13 |
--------------------------------------------------------------------------------
/0x06-python-classes/100-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | SinglyLinkedList = __import__('100-singly_linked_list').SinglyLinkedList
3 |
4 | sll = SinglyLinkedList()
5 | sll.sorted_insert(2)
6 | sll.sorted_insert(5)
7 | sll.sorted_insert(3)
8 | sll.sorted_insert(10)
9 | sll.sorted_insert(1)
10 | sll.sorted_insert(-4)
11 | sll.sorted_insert(-3)
12 | sll.sorted_insert(4)
13 | sll.sorted_insert(5)
14 | sll.sorted_insert(12)
15 | sll.sorted_insert(3)
16 | print(sll)
17 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/5-request_store.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const request = require('request');
4 | const fs = require('fs');
5 | const url = process.argv[2];
6 | const file = process.argv[3];
7 |
8 | request(url, (error, response, body) => {
9 | if (error) {
10 | console.log(error);
11 | } else {
12 | fs.writeFile(file, body, 'utf8', (error) => {
13 | if (error) {
14 | console.log(error);
15 | }
16 | });
17 | }
18 | });
19 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/2-args.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | if __name__ == "__main__":
4 | """Print the number of and list of arguments."""
5 | import sys
6 |
7 | count = len(sys.argv) - 1
8 | if count == 0:
9 | print("0 arguments.")
10 | elif count == 1:
11 | print("1 argument:")
12 | else:
13 | print("{} arguments:".format(count))
14 | for i in range(count):
15 | print("{}: {}".format(i + 1, sys.argv[i + 1]))
16 |
--------------------------------------------------------------------------------
/0x06-python-classes/4-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Square = __import__('4-square').Square
3 |
4 | my_square = Square(89)
5 | print("Area: {} for size: {}".format(my_square.area(), my_square.size))
6 |
7 | my_square.size = 3
8 | print("Area: {} for size: {}".format(my_square.area(), my_square.size))
9 |
10 | try:
11 | my_square.size = "5 feet"
12 | print("Area: {} for size: {}".format(my_square.area(), my_square.size))
13 | except Exception as e:
14 | print(e)
15 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/101-lazy_matrix_mul.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | """This module contains a function that multiplies two matrices"""
4 |
5 | import numpy as np
6 |
7 |
8 | def lazy_matrix_mul(m_a, m_b):
9 | """Return the multiplication of two matrices.
10 | Args:
11 | m_a (list of lists of ints/floats): The first matrix.
12 | m_b (list of lists of ints/floats): The second matrix.
13 | """
14 |
15 | return (np.matmul(m_a, m_b))
16 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/101-not_a_comedy.sql:
--------------------------------------------------------------------------------
1 | -- lists all shows without the genre Comedy in the database hbtn_0d_tvshows
2 | -- uses a database to list all rows not linked to one row
3 | SELECT title
4 | FROM tv_shows
5 | WHERE title NOT IN
6 | (SELECT title
7 | FROM tv_shows
8 | LEFT JOIN tv_show_genres ON tv_shows.id = tv_show_genres.show_id
9 | LEFT JOIN tv_genres ON tv_show_genres.genre_id = tv_genres.id
10 | WHERE tv_genres.name = 'Comedy')
11 | GROUP BY title
12 | ORDER BY title ASC;
13 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/7-cities.sql:
--------------------------------------------------------------------------------
1 | -- creates the database hbtn_0d_usa and the table cities (in the database hbtn_0d_usa) on your MySQL server
2 | -- creates a database
3 | CREATE DATABASE IF NOT EXISTS hbtn_0d_usa;
4 | -- use a database
5 | USE hbtn_0d_usa;
6 | -- creates a table
7 | CREATE TABLE IF NOT EXISTS cities (id INT UNIQUE AUTO_INCREMENT NOT NULL,
8 | state_id INT NOT NULL,
9 | name VARCHAR(256) NOT NULL,
10 | PRIMARY KEY(id),
11 | FOREIGN KEY(state_id) REFERENCES states(id));
12 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/1-write_file.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a file-writing function."""
3 |
4 |
5 | def write_file(filename="", text=""):
6 | """Write a string to a UTF8 text file.
7 | Args:
8 | filename (str): The name of the file to write.
9 | text (str): The text to write to the file.
10 | Returns:
11 | The number of characters written.
12 | """
13 | with open(filename, "w", encoding="utf-8") as f:
14 | return f.write(text)
15 |
--------------------------------------------------------------------------------
/0x0E-SQL_more_queries/100-not_my_genres.sql:
--------------------------------------------------------------------------------
1 | -- uses the hbtn_0d_tvshows database to list all genres not linked to the show Dexter
2 | -- uses a database to list all rows not linked to one row
3 | SELECT name
4 | FROM tv_genres
5 | WHERE name NOT IN
6 | (SELECT name
7 | FROM tv_genres
8 | LEFT JOIN tv_show_genres ON tv_genres.id = tv_show_genres.genre_id
9 | LEFT JOIN tv_shows ON tv_show_genres.show_id = tv_shows.id
10 | WHERE tv_shows.title = 'Dexter')
11 | GROUP BY name
12 | ORDER BY name ASC;
13 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/6-model_state.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script defines a State class and
4 | a Base class to work with MySQLAlchemy ORM.
5 | """
6 | import sys
7 | from model_state import Base, State
8 |
9 | from sqlalchemy import (create_engine)
10 |
11 | if __name__ == "__main__":
12 | engine = create_engine('mysql+mysqldb://{}:{}@localhost/{}'.format(sys.argv[1], sys.argv[2], sys.argv[3]), pool_pre_ping=True)
13 | Base.metadata.create_all(engine)
14 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/9-student.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Module defines a class Student"""
3 |
4 |
5 | class Student:
6 | """Represent a student."""
7 |
8 | def __init__(self, first_name, last_name, age):
9 | """Initializes a new Student"""
10 | self.first_name = first_name
11 | self.last_name = last_name
12 | self.age = age
13 |
14 | def to_json(self):
15 | """Gets a dictionary representation of the Student"""
16 | return self.__dict__
17 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/11-square.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a Rectangle subclass Square."""
3 | Rectangle = __import__('9-rectangle').Rectangle
4 |
5 |
6 | class Square(Rectangle):
7 | """Represent a square."""
8 |
9 | def __init__(self, size):
10 | """Initialize a new square.
11 | Args:
12 | size (int): The size of the new square.
13 | """
14 | self.integer_validator("size", size)
15 | super().__init__(size, size)
16 | self.__size = size
17 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/7-add_tuple.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | def add_tuple(tuple_a=(), tuple_b=()):
4 | if len(tuple_a) < 2:
5 | if len(tuple_a) == 0:
6 | tuple_a = 0, 0
7 | else:
8 | tuple_a = tuple_a[0], 0
9 |
10 | if len(tuple_b) < 2:
11 | if len(tuple_b) == 0:
12 | tuple_b = 0, 0
13 | else:
14 | tuple_b = tuple_b[0], 0
15 |
16 | added_tuple = tuple_a[0] + tuple_b[0], tuple_a[1] + tuple_b[1]
17 | return added_tuple
18 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/4-inherits_from.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines an inherited class-checking function."""
3 |
4 |
5 | def inherits_from(obj, a_class):
6 | """ Args:
7 | obj (any): The object to check.
8 | a_class (type): The class to match the type of obj to
9 |
10 | Returns true if object is an instance of a class that inherited
11 | (directly or indirectly) from the specified class; otherwise False
12 | """
13 | return (issubclass(type(obj), a_class) and type(obj) != a_class)
14 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/10-square.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a Rectangle subclass/child Square."""
3 | Rectangle = __import__('9-rectangle').Rectangle
4 |
5 |
6 | class Square(Rectangle):
7 | """Represent a square."""
8 |
9 | def __init__(self, size):
10 | """Initialize a new square.
11 | Args:
12 | size (int): The size of the new square.
13 | """
14 | self.integer_validator("size", size)
15 | super().__init__(size, size)
16 | self.__size = size
17 |
--------------------------------------------------------------------------------
/0x11-python-network_1/10-my_github.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Uses the GitHub API to display a GitHub ID based on given credentials.
3 | Usage: ./10-my_github.py
4 | - Uses Basic Authentication to access the ID.
5 | """
6 | import sys
7 | import requests
8 | from requests.auth import HTTPBasicAuth
9 |
10 |
11 | if __name__ == "__main__":
12 | auth = HTTPBasicAuth(sys.argv[1], sys.argv[2])
13 | r = requests.get("https://api.github.com/user", auth=auth)
14 | print(r.json().get("id"))
15 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/12-pascal_triangle.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Writes a Pascal's Triangle function"""
3 |
4 |
5 | def pascal_triangle(n):
6 | """Represents Pascal's Triangle of size n"""
7 | if n <= 0:
8 | return []
9 |
10 | triangles = [[1]]
11 | while len(triangles) != n:
12 | tri = triangles[-1]
13 | tmp = [1]
14 | for i in range(len(tri) - 1):
15 | tmp.append(tri[i] + tri[i + 1])
16 | tmp.append(1)
17 | triangles.append(tmp)
18 | return triangles
19 |
--------------------------------------------------------------------------------
/0x0D-SQL_introduction/9-full_creation.sql:
--------------------------------------------------------------------------------
1 | -- Creates and fills a table second_table with attributes id, name and score in my MySQL server with multiple rows.
2 | CREATE TABLE IF NOT EXISTS `second_table` (`id` INT, `name` VARCHAR(256), `score` INT);
3 | INSERT INTO `second_table` (`id`, `name`, `score`) VALUES (1, "John", 10);
4 | INSERT INTO `second_table` (`id`, `name`, `score`) VALUES (2, "Alex", 3);
5 | INSERT INTO `second_table` (`id`, `name`, `score`) VALUES (3, "Bob", 14);
6 | INSERT INTO `second_table` (`id`, `name`, `score`) VALUES (4, "George", 8);
7 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/6-max_integer_test.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Module to find the max integer in a list
3 | """
4 |
5 |
6 | def max_integer(list=[]):
7 | """Function to find and return the max integer in a list of integers
8 | If the list is empty, the function returns None
9 | """
10 | if len(list) == 0:
11 | return None
12 | result = list[0]
13 | i = 1
14 | while i < len(list):
15 | if list[i] > result:
16 | result = list[i]
17 | i += 1
18 | return result
19 |
--------------------------------------------------------------------------------
/0x15-javascript-web_jquery/103-script.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | $("INPUT#btn_translate").click(fetchTranslation);
3 | $("INPUT#language_code").keyup(function (event) {
4 | if (event.keyCode === 13) {
5 | fetchTranslation();
6 | }
7 | });
8 |
9 | function fetchTranslation() {
10 | const language_code = $("INPUT#language_code").val();
11 | $.getJSON(
12 | `https://fourtonfish.com/hellosalut/hello/?lang=${language_code}`,
13 | function (data) {
14 | $("#hello").text(data.hello);
15 | }
16 | );
17 | }
18 | });
19 |
--------------------------------------------------------------------------------
/0x11-python-network_1/0-hbtn_status.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Fetches https://alx-intranet.hbtn.io/status."""
3 | import urllib.request
4 |
5 |
6 | if __name__ == "__main__":
7 | request = urllib.request.Request("https://alx-intranet.hbtn.io/status")
8 | with urllib.request.urlopen(request) as response:
9 | body = response.read()
10 | print("Body response:")
11 | print("\t- type: {}".format(type(body)))
12 | print("\t- content: {}".format(body))
13 | print("\t- utf8 content: {}".format(body.decode("utf-8")))
14 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/1-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | safe_print_integer = __import__('1-safe_print_integer').safe_print_integer
3 |
4 | value = 89
5 | has_been_print = safe_print_integer(value)
6 | if not has_been_print:
7 | print("{} is not an integer".format(value))
8 |
9 | value = -89
10 | has_been_print = safe_print_integer(value)
11 | if not has_been_print:
12 | print("{} is not an integer".format(value))
13 |
14 | value = "School"
15 | has_been_print = safe_print_integer(value)
16 | if not has_been_print:
17 | print("{} is not an integer".format(value))
18 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/2-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | safe_print_list_integers = \
3 | __import__('2-safe_print_list_integers').safe_print_list_integers
4 |
5 | my_list = [1, 2, 3, 4, 5]
6 |
7 | nb_print = safe_print_list_integers(my_list, 2)
8 | print("nb_print: {:d}".format(nb_print))
9 |
10 | my_list = [1, 2, 3, "School", 4, 5, [1, 2, 3]]
11 | nb_print = safe_print_list_integers(my_list, len(my_list))
12 | print("nb_print: {:d}".format(nb_print))
13 |
14 | nb_print = safe_print_list_integers(my_list, len(my_list) + 2)
15 | print("nb_print: {:d}".format(nb_print))
16 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/102-tests.py:
--------------------------------------------------------------------------------
1 | import ctypes
2 |
3 | lib = ctypes.CDLL('./libPython.so')
4 | lib.print_python_string.argtypes = [ctypes.py_object]
5 | s = "The spoon does not exist"
6 | lib.print_python_string(s)
7 | s = "ложка не существует"
8 | lib.print_python_string(s)
9 | s = "La cuillère n'existe pas"
10 | lib.print_python_string(s)
11 | s = "勺子不存在"
12 | lib.print_python_string(s)
13 | s = "숟가락은 존재하지 않는다."
14 | lib.print_python_string(s)
15 | s = "スプーンは存在しない"
16 | lib.print_python_string(s)
17 | s = b"The spoon does not exist"
18 | lib.print_python_string(s)
19 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/1-last_digit.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | import random
3 | number = random.randint(-10000, 10000)
4 | if number < 0:
5 | lastdigit = number % -10
6 | else:
7 | lastdigit = number % 10
8 | if lastdigit > 5:
9 | print("Last digit of {:d} is {:d} and is greater than 5"
10 | .format(number, lastdigit))
11 | elif lastdigit < 6 and lastdigit != 0:
12 | print("Last digit of {:d} is {:d} and is less than 6 and not 0"
13 | .format(number, lastdigit))
14 | else:
15 | print("Last digit of {:d} is 0 and is 0".format(number))
16 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/7-add_item.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Module adds all arguments to a Python list and save them to a file."""
3 |
4 |
5 | import sys
6 |
7 | if __name__ == "__main__":
8 | save_to_json_file = __import__('5-save_to_json_file').save_to_json_file
9 | load_from_json_file = \
10 | __import__('6-load_from_json_file').load_from_json_file
11 |
12 | try:
13 | items = load_from_json_file("add_item.json")
14 | except FileNotFoundError:
15 | items = []
16 | items.extend(sys.argv[1:])
17 | save_to_json_file(items, "add_item.json")
18 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/6-square.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | /**
3 | * Square class that inherits from previous square class
4 | */
5 | const PrevSquare = require('./5-square');
6 |
7 | class Square extends PrevSquare {
8 | charPrint (c) {
9 | const myChar = c === undefined ? 'X' : c;
10 | for (let i = 0; i < this.height; i++) {
11 | let myVar = '';
12 | let y = 0;
13 | while (y < this.width) {
14 | myVar += myChar;
15 | y++;
16 | }
17 |
18 | console.log(myVar);
19 | }
20 | }
21 | }
22 |
23 | module.exports = Square;
24 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/4-starwars_count.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const request = require('request');
4 | const url = process.argv[2];
5 | const characterId = '18';
6 | let count = 0;
7 |
8 | request.get(url, (error, response, body) => {
9 | if (error) {
10 | console.log(error);
11 | } else {
12 | const data = JSON.parse(body);
13 | data.results.forEach((film) => {
14 | film.characters.forEach((character) => {
15 | if (character.includes(characterId)) {
16 | count += 1;
17 | }
18 | });
19 | });
20 | console.log(count);
21 | }
22 | });
23 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/lists.h:
--------------------------------------------------------------------------------
1 | #ifndef LISTS_H
2 | #define LISTS_H
3 |
4 | #include
5 |
6 | /**
7 | * struct listint_s - singly linked list
8 | * @n: integer
9 | * @next: points to the next node
10 | *
11 | * Description: singly linked list node structure
12 | *
13 | */
14 | typedef struct listint_s
15 | {
16 | int n;
17 | struct listint_s *next;
18 | } listint_t;
19 |
20 | size_t print_listint(const listint_t *h);
21 | listint_t *add_nodeint(listint_t **head, const int n);
22 | void free_listint(listint_t *head);
23 | int check_cycle(listint_t *list);
24 |
25 | #endif /* LISTS_H */
26 |
--------------------------------------------------------------------------------
/0x11-python-network_1/3-error_code.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Sends a request to a given URL and displays the response body.
3 | Usage: ./3-error_code.py
4 | - Handles HTTP errors.
5 | """
6 | import sys
7 | import urllib.error
8 | import urllib.request
9 |
10 |
11 | if __name__ == "__main__":
12 | url = sys.argv[1]
13 |
14 | request = urllib.request.Request(url)
15 | try:
16 | with urllib.request.urlopen(request) as response:
17 | print(response.read().decode("ascii"))
18 | except urllib.error.HTTPError as e:
19 | print("Error code: {}".format(e.code))
20 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/100-print_python_list_info.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | /**
6 | * print_python_list_info - prints some basic info about pytohn list
7 | * @p: python object
8 | **/
9 |
10 | void print_python_list_info(PyObject *p)
11 | {
12 | long int size = PyList_Size(p);
13 | int i;
14 | PyListObject *obj = (PyListObject *)p;
15 |
16 | printf("[*] Size of the Python List = %li\n", size);
17 | printf("[*] Allocated = %li\n", obj->allocated);
18 | for (i = 0; i < size; i++)
19 | printf("Element %i: %s\n", i, Py_TYPE(obj->ob_item[i])->tp_name);
20 | }
21 |
--------------------------------------------------------------------------------
/0x09-python-everything_is_object/README.md:
--------------------------------------------------------------------------------
1 | ## 0x09. Python - Everything is object
2 |
3 | ### Requirements
4 |
5 | ___Python Scripts___
6 | * Allowed editors: vi, vim, emacs
7 | * All your files will be interpreted/compiled on Ubuntu 20.04 LTS using python3 (version 3.8.5)
8 | * All your files should end with a new line
9 | * The first line of all your files should be exactly #!/usr/bin/python3
10 | * A README.md file, at the root of the folder of the project, is mandatory
11 | * Your code should use the pycodestyle (version 2.8.*)
12 | * All your files must be executable
13 | * The length of your files will be tested using wc
14 |
--------------------------------------------------------------------------------
/0x11-python-network_1/7-error_code.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | Sends a request to the URL and displays the body of the response.
4 | """
5 | import requests
6 | from sys import argv
7 |
8 |
9 | def main(argv):
10 | """
11 | Method that manage urllib.error.HTTPError exceptions and
12 | print: Error code: followed by the HTTP status code
13 | """
14 | url = argv[1]
15 | r = requests.get(url)
16 | if r.status_code == requests.codes.ok:
17 | print(r.text)
18 | else:
19 | print("Error code: {}".format(r.status_code))
20 |
21 |
22 | if __name__ == "__main__":
23 | main(argv)
24 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/3-rectangle.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | /**
3 | * Check the parameters provided
4 | */
5 | class Rectangle {
6 | constructor (w, h) {
7 | if (typeof w === 'number' && w > 0 && typeof h === 'number' && h > 0) {
8 | this.width = w;
9 | this.height = h;
10 | }
11 | }
12 |
13 | print () {
14 | for (let i = 0; i < this.height; i++) {
15 | let myVar = '';
16 | let y = 0;
17 | while (y < this.width) {
18 | myVar += 'X';
19 | y++;
20 | }
21 |
22 | console.log(myVar);
23 | }
24 | }
25 | }
26 | module.exports = Rectangle;
27 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/lists.h:
--------------------------------------------------------------------------------
1 | #ifndef LISTS_H
2 | #define LISTS_H
3 |
4 | #include
5 | /**
6 | * struct listint_s - singly linked list
7 | * @n: integer
8 | * @next: points to the next node
9 | *
10 | * Description: singly linked list node structure
11 | * for project
12 | */
13 | typedef struct listint_s
14 | {
15 | int n;
16 | struct listint_s *next;
17 | } listint_t;
18 |
19 | size_t print_listint(const listint_t *h);
20 | listint_t *add_nodeint_end(listint_t **head, const int n);
21 | void free_listint(listint_t *head);
22 |
23 | int is_palindrome(listint_t **head);
24 |
25 | #endif /* LISTS_H */
26 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/102-concat.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const fs = require('fs');
3 |
4 | const fileA = process.argv[2];
5 | const fileB = process.argv[3];
6 | const fileC = process.argv[4];
7 |
8 | if (
9 | fs.existsSync(fileA) &&
10 | fs.statSync(fileA).isFile &&
11 | fs.existsSync(fileB) &&
12 | fs.statSync(fileB).isFile &&
13 | fileC !== undefined
14 | ) {
15 | const fileAContent = fs.readFileSync(fileA);
16 | const fileBContent = fs.readFileSync(fileB);
17 | const stream = fs.createWriteStream(fileC);
18 |
19 | stream.write(fileAContent);
20 | stream.write(fileBContent);
21 | stream.end();
22 | }
23 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/lists.h:
--------------------------------------------------------------------------------
1 | #ifndef LISTS_H
2 | #define LISTS_H
3 |
4 | #include
5 | /**
6 | * struct listint_s - singly linked list
7 | * @n: integer
8 | * @next: points to the next node
9 | *
10 | * Description: singly linked list node structure
11 | *
12 | */
13 | typedef struct listint_s
14 | {
15 | int n;
16 | struct listint_s *next;
17 | } listint_t;
18 |
19 | size_t print_listint(const listint_t *h);
20 | listint_t *add_nodeint_end(listint_t **head, const int n);
21 | void free_listint(listint_t *head);
22 |
23 | listint_t *insert_node(listint_t **head, int number);
24 |
25 | #endif /* LISTS_H */
26 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/102-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | complex_delete = __import__('102-complex_delete').complex_delete
3 | print_sorted_dictionary = \
4 | __import__('6-print_sorted_dictionary').print_sorted_dictionary
5 |
6 | a_dictionary = {'lang': "C", 'track': "Low", 'pref': "C", 'ids': [1, 2, 3]}
7 | new_dict = complex_delete(a_dictionary, 'C')
8 | print_sorted_dictionary(a_dictionary)
9 | print("--")
10 | print_sorted_dictionary(new_dict)
11 |
12 | print("--")
13 | print("--")
14 | new_dict = complex_delete(a_dictionary, 'c_is_fun')
15 | print_sorted_dictionary(a_dictionary)
16 | print("--")
17 | print_sorted_dictionary(new_dict)
18 |
--------------------------------------------------------------------------------
/0x11-python-network_1/1-hbtn_header.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | Displays the value of the X-Request-Id variable
4 | found in the header of the response
5 | """
6 | import urllib.request
7 | from sys import argv
8 |
9 |
10 | def main(argv):
11 | """
12 | Method that takes in a URL, sends a request to the URL
13 | and displays the value of the X-Request-Id variable
14 | found in the header of the response
15 | """
16 | url = argv
17 | with urllib.request.urlopen(url) as response:
18 | headers = response.info()
19 | print(headers['X-Request-Id'])
20 |
21 | if __name__ == "__main__":
22 | main(argv[1])
23 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/8-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | simple_delete = __import__('8-simple_delete').simple_delete
3 | print_sorted_dictionary = \
4 | __import__('6-print_sorted_dictionary').print_sorted_dictionary
5 |
6 | a_dictionary = { 'language': "C", 'Number': 89, 'track': "Low", 'ids': [1, 2, 3] }
7 | new_dict = simple_delete(a_dictionary, 'track')
8 | print_sorted_dictionary(a_dictionary)
9 | print("--")
10 | print_sorted_dictionary(new_dict)
11 |
12 | print("--")
13 | print("--")
14 | new_dict = simple_delete(a_dictionary, 'c_is_fun')
15 | print_sorted_dictionary(a_dictionary)
16 | print("--")
17 | print_sorted_dictionary(new_dict)
18 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/12-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """ Roman to Integer test file
3 | """
4 | roman_to_int = __import__('12-roman_to_int').roman_to_int
5 |
6 | roman_number = "X"
7 | print("{} = {}".format(roman_number, roman_to_int(roman_number)))
8 |
9 | roman_number = "VII"
10 | print("{} = {}".format(roman_number, roman_to_int(roman_number)))
11 |
12 | roman_number = "IX"
13 | print("{} = {}".format(roman_number, roman_to_int(roman_number)))
14 |
15 | roman_number = "LXXXVII"
16 | print("{} = {}".format(roman_number, roman_to_int(roman_number)))
17 |
18 | roman_number = "DCCVII"
19 | print("{} = {}".format(roman_number, roman_to_int(roman_number)))
20 |
--------------------------------------------------------------------------------
/0x04-python-more_data_structures/7-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | update_dictionary = __import__('7-update_dictionary').update_dictionary
3 | print_sorted_dictionary = __import__('6-print_sorted_dictionary').print_sorted_dictionary
4 |
5 | a_dictionary = { 'language': "C", 'number': 89, 'track': "Low level" }
6 | new_dict = update_dictionary(a_dictionary, 'language', "Python")
7 | print_sorted_dictionary(new_dict)
8 | print("--")
9 | print_sorted_dictionary(a_dictionary)
10 |
11 | print("--")
12 | print("--")
13 |
14 | new_dict = update_dictionary(a_dictionary, 'city', "San Francisco")
15 | print_sorted_dictionary(new_dict)
16 | print("--")
17 | print_sorted_dictionary(a_dictionary)
18 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/0-select_states.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script lists all states from the
4 | database `hbtn_0e_0_usa`.
5 | """
6 |
7 | import MySQLdb
8 | from sys import argv
9 |
10 | if __name__ == '__main__':
11 | """
12 | Access to the database and get the states
13 | from the database.
14 | """
15 | db_connect = MySQLdb.connect(
16 | host="localhost", user=argv[1], port=3306, passwd=argv[2], db=argv[3])
17 |
18 | db_cursor = db_connect.cursor()
19 |
20 | db_cursor.execute("SELECT * FROM states")
21 |
22 | rows_selected = db_cursor.fetchall()
23 |
24 | for row in rows_selected:
25 | print(row)
26 |
--------------------------------------------------------------------------------
/0x06-python-classes/103-magic_class.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """writing a docstring"""
3 | import math
4 |
5 |
6 | class MagicClass:
7 | """set up the magic"""
8 |
9 | def __init__(self, radius=0):
10 | """ writing another docstring """
11 | self.__radius = 0
12 | if type(radius) is not int and type(radius) is not float:
13 | raise TypeError('radius must be a number')
14 | self.__radius = radius
15 |
16 | def area(self):
17 | """again with the docstring"""
18 | return self.__radius ** 2 * math.pi
19 |
20 | def circumference(self):
21 | """such docstring"""
22 | return 2 * math.pi * self.__radius
23 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/101-starwars_characters.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const request = require('request');
3 | const url = 'https://swapi-api.hbtn.io/api/films/' + process.argv[2];
4 | request(url, function (error, response, body) {
5 | if (!error) {
6 | const characters = JSON.parse(body).characters;
7 | printCharacters(characters, 0);
8 | }
9 | });
10 |
11 | function printCharacters (characters, index) {
12 | request(characters[index], function (error, response, body) {
13 | if (!error) {
14 | console.log(JSON.parse(body).name);
15 | if (index + 1 < characters.length) {
16 | printCharacters(characters, index + 1);
17 | }
18 | }
19 | });
20 | }
21 |
--------------------------------------------------------------------------------
/0x00-python-hello_world/10-check_cycle.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "lists.h"
3 |
4 | /**
5 | * check_cycle - Checks if a singly-linked list contains a cycle.
6 | * @list: A singly-linked list.
7 | *
8 | * Return: If there is no cycle - 0.
9 | * If there is a cycle - 1.
10 | */
11 | int check_cycle(listint_t *list)
12 | {
13 | listint_t *slow, *fast;
14 |
15 | if (list == NULL || list->next == NULL)
16 | return (0);
17 |
18 | slow = list->next;
19 | fast = list->next->next;
20 |
21 | while (slow && fast && fast->next)
22 | {
23 | if (slow == fast)
24 | return (1);
25 |
26 | slow = slow->next;
27 | fast = fast->next->next;
28 | }
29 |
30 | return (0);
31 | }
32 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/100-my_calculator.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | if __name__ == "__main__":
4 | """Handle basic arithmetic operations."""
5 | from calculator_1 import add, sub, mul, div
6 | import sys
7 |
8 | if len(sys.argv) - 1 != 3:
9 | print("Usage: ./100-my_calculator.py ")
10 | sys.exit(1)
11 |
12 | ops = {"+": add, "-": sub, "*": mul, "/": div}
13 | if sys.argv[2] not in list(ops.keys()):
14 | print("Unknown operator. Available operators: +, -, * and /")
15 | sys.exit(1)
16 |
17 | a = int(sys.argv[1])
18 | b = int(sys.argv[3])
19 | print("{} {} {} = {}".format(a, sys.argv[2], b, ops[sys.argv[2]](a, b)))
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | # Solutions to Python related tasks.
6 | ___
7 | [](https://github.com/Innocentsax/standard-readme)
8 |
9 | This repo is for the second sprint of the ALX Software Engineering Programme. During this sprint we will be learning and practicing higher level programming languages Python is the primary language we are going to be using.
10 |
11 | Hence, this repo will contain all the solutions I submit for our daily tasks.
12 |
13 | ## Author
14 | ---
15 | © **UDO INNOCENT CHARLES**
16 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/8-rectangle.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a class Rectangle that inherits from BaseGeometry."""
3 | BaseGeometry = __import__('7-base_geometry').BaseGeometry
4 |
5 |
6 | class Rectangle(BaseGeometry):
7 | """Represent a class to define rectangle using BaseGeometry."""
8 |
9 | def __init__(self, width, height):
10 | """Intialize a new Rectangle.
11 | Args:
12 | width (int): The width of the new Rectangle.
13 | height (int): The height of the new Rectangle.
14 | """
15 | self.integer_validator("width", width)
16 | self.__width = width
17 | self.integer_validator("height", height)
18 | self.__height = height
19 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/model_state.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script defines a State class and
4 | a Base class to work with MySQLAlchemy ORM.
5 | """
6 |
7 | from sqlalchemy import Column, Integer, String
8 | from sqlalchemy.ext.declarative import declarative_base
9 |
10 | Base = declarative_base()
11 |
12 |
13 | class State(Base):
14 | """State class
15 |
16 | Attributes:
17 | __tablename__ (str): The table name of the class
18 | id (int): The State id of the class
19 | name (str): The State name of the class
20 | """
21 | __tablename__ = 'states'
22 |
23 | id = Column(Integer, primary_key=True)
24 | name = Column(String(128), nullable=False)
25 |
--------------------------------------------------------------------------------
/0x06-python-classes/2-square.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # 0-square.py by UDO INNOCENT
3 | """A module that defines a square """
4 |
5 |
6 | class Square:
7 | """A class that represents a square"""
8 |
9 | def __init__(self, size=0):
10 | """Initializing this square class
11 | Args:
12 | size: represnets the size of the square defined
13 | Raises:
14 | TypeError: if size is not integer
15 | ValueError: if size is less than zero
16 | """
17 |
18 | if not isinstance(size, int):
19 | raise TypeError('size must be an integer')
20 | if size < 0:
21 | raise ValueError('size must be >= 0')
22 |
23 | self.__size = size
24 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/100-append_after.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Write a mudule that permit a text file insertion function."""
3 |
4 |
5 | def append_after(filename="", search_string="", new_string=""):
6 | """Insert text after each line containing a given string in a file.
7 | Args:
8 | filename (str): The name of the file.
9 | search_string (str): The string to search for within the file.
10 | new_string (str): The string to insert.
11 | """
12 | text = ""
13 | with open(filename) as r:
14 | for line in r:
15 | text += line
16 | if search_string in line:
17 | text += new_string
18 | with open(filename, "w") as w:
19 | w.write(text)
20 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/100-starwars_characters.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const request = require('request');
4 |
5 | const movieId = process.argv[2];
6 | const url = `https://swapi.dev/api/films/${movieId}/`;
7 |
8 | request.get(url, (error, response, body) => {
9 | if (error) {
10 | console.log(error);
11 | return;
12 | }
13 |
14 | const data = JSON.parse(body);
15 | const characters = data.characters;
16 | for (const character of characters) {
17 | request(character, (error, response, body) => {
18 | if (error) {
19 | console.log(error);
20 | return;
21 | }
22 | const characterData = JSON.parse(body);
23 | console.log(characterData.name);
24 | });
25 | }
26 | });
27 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/0-add_integer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This module has one function that adds up 2 integers
4 | """
5 |
6 |
7 | def add_integer(a, b=98):
8 | """Return the sum of two integers or floats as integers
9 | Args:
10 | a: first argument
11 | b: second argument
12 | Returns:
13 | Sum of the two arguments
14 | Raises:
15 | TypeError: If either of the arguments not an integer or a float
16 | """
17 | if ((not isinstance(a, int) and not isinstance(a, float))):
18 | raise TypeError("a must be an integer")
19 | if ((not isinstance(b, int) and not isinstance(b, float))):
20 | raise TypeError("b must be an integer")
21 | return (int(a) + int(b))
22 |
--------------------------------------------------------------------------------
/0x11-python-network_1/2-post_email.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | POST request to the passed URL with the email as a parameter
4 | """
5 | import urllib.request
6 | from sys import argv
7 |
8 |
9 | def main(argv):
10 | """
11 | Sends a POST request to the passed URL with the email as a parameter,
12 | and displays the body of the response (decoded in utf-8)
13 | """
14 | values = {'email': argv[2]}
15 | data = urllib.parse.urlencode(values)
16 | data = data.encode('utf8')
17 | url = argv[1]
18 | req = urllib.request.Request(url, data)
19 | with urllib.request.urlopen(req) as response:
20 | result = response.read()
21 | print(result.decode('utf8'))
22 |
23 | if __name__ == "__main__":
24 | main(argv)
25 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/3-say_my_name.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """"
3 | This module contains a function that prints a name
4 | """
5 |
6 |
7 | def say_my_name(first_name, last_name=""):
8 | '''This function prints name ( )
9 | Args:
10 | first_name (str): The fisrt name to be printed
11 | last_name (str): The last name to be printed
12 | Raises:
13 | TypeError: If either the first_name and last_name are not strings
14 | '''
15 |
16 | if not isinstance(first_name, str):
17 | raise TypeError("first_name must be a string")
18 |
19 | if not isinstance(last_name, str):
20 | raise TypeError("last_name must be a string")
21 | print(f"My name is {first_name} {last_name}")
22 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/model_city.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script defines a City class
4 | to work with MySQLAlchemy ORM.
5 | """
6 | from model_state import Base, State
7 | from sqlalchemy import Column, Integer, String, ForeignKey
8 |
9 |
10 | class City(Base):
11 | """City class
12 | Attributes:
13 | __tablename__ (str): The table name of the class
14 | id (int): The id of the class
15 | name (str): The name of the class
16 | state_id (int): The state the city belongs to
17 | """
18 |
19 | __tablename__ = 'cities'
20 |
21 | id = Column(Integer, primary_key=True)
22 | state_id = Column(Integer, ForeignKey('states.id'), nullable=False)
23 | name = Column(String(128), nullable=False)
24 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/README.md:
--------------------------------------------------------------------------------
1 | # Javascript Web Scrapping
2 | 
3 |
4 | ## Project Requirements
5 |
6 | ### General
7 | - Allowed editors: vi, vim, emacs
8 | - All your files will be interpreted on `Ubuntu 14.04 LTS` using node (version 10.14.x)
9 | - All your files should end with a new line
10 | - The first line of all your files should be exactly `#!/usr/bin/node`
11 | - A README.md file, at the root of the folder of the project, is mandatory
12 | - Your code should be semistandard compliant. Rules of Standard + semicolons on top. Also as reference: AirBnB style
13 | - All your files must be executable
14 | - The length of your files will be tested using wc
15 | - You are not allowed to use `var`
16 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/relationship_city.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script defines a City class
4 | to work with MySQLAlchemy ORM.
5 | """
6 |
7 | from relationship_state import Base, State
8 | from sqlalchemy import Column, Integer, String, ForeignKey
9 |
10 |
11 | class City(Base):
12 | """City class
13 | Attributes:
14 | __tablename__ (str): The table name of the class
15 | id (int): The id of the class
16 | name (str): The name of the class
17 | state_id (int): The state the city belongs to
18 | """
19 | __tablename__ = 'cities'
20 |
21 | id = Column(Integer, primary_key=True)
22 | name = Column(String(128), nullable=False)
23 | state_id = Column(Integer, ForeignKey('states.id'), nullable=False)
24 |
--------------------------------------------------------------------------------
/0x06-python-classes/2-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | Square = __import__('2-square').Square
3 |
4 | my_square_1 = Square(3)
5 | print(type(my_square_1))
6 | print(my_square_1.__dict__)
7 |
8 | my_square_2 = Square()
9 | print(type(my_square_2))
10 | print(my_square_2.__dict__)
11 |
12 | try:
13 | print(my_square_1.size)
14 | except Exception as e:
15 | print(e)
16 |
17 | try:
18 | print(my_square_1.__size)
19 | except Exception as e:
20 | print(e)
21 |
22 | try:
23 | my_square_3 = Square("3")
24 | print(type(my_square_3))
25 | print(my_square_3.__dict__)
26 | except Exception as e:
27 | print(e)
28 |
29 | try:
30 | my_square_4 = Square(-89)
31 | print(type(my_square_4))
32 | print(my_square_4.__dict__)
33 | except Exception as e:
34 | print(e)
35 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/102-python.c:
--------------------------------------------------------------------------------
1 | #include "Python.h"
2 |
3 | /**
4 | * print_python_string - Prints information about Python strings.
5 | * @p: A PyObject string object.
6 | */
7 |
8 | void print_python_string(PyObject *p)
9 | {
10 | long int length;
11 |
12 | fflush(stdout);
13 |
14 | printf("[.] string object info\n");
15 | if (strcmp(p->ob_type->tp_name, "str") != 0)
16 | {
17 | printf(" [ERROR] Invalid String Object\n");
18 | return;
19 | }
20 |
21 | length = ((PyASCIIObject *)(p))->length;
22 |
23 | if (PyUnicode_IS_COMPACT_ASCII(p))
24 | printf(" type: compact ascii\n");
25 | else
26 | printf(" type: compact unicode object\n");
27 | printf(" length: %ld\n", length);
28 | printf(" value: %ls\n", PyUnicode_AsWideCharString(p, &length));
29 | }
30 |
--------------------------------------------------------------------------------
/0x14-javascript-web_scraping/6-completed_tasks.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 |
3 | const request = require('request');
4 | const url = process.argv[2];
5 |
6 | request(url, function (err, response, body) {
7 | if (err) {
8 | console.log(err);
9 | } else if (response.statusCode === 200) {
10 | const completed = {};
11 | const tasks = JSON.parse(body);
12 | for (const i in tasks) {
13 | const task = tasks[i];
14 | if (task.completed === true) {
15 | if (completed[task.userId] === undefined) {
16 | completed[task.userId] = 1;
17 | } else {
18 | completed[task.userId]++;
19 | }
20 | }
21 | }
22 | console.log(completed);
23 | } else {
24 | console.log('An error occured. Status code: ' + response.statusCode);
25 | }
26 | });
27 |
--------------------------------------------------------------------------------
/0x11-python-network_1/8-json_api.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Sends a POST request to http://0.0.0.0:5000/search_user with a given letter.
3 | Usage: ./8-json_api.py
4 | - The letter is sent as the value of the variable `q`.
5 | - If no letter is provided, sends `q=""`.
6 | """
7 | import sys
8 | import requests
9 |
10 |
11 | if __name__ == "__main__":
12 | letter = "" if len(sys.argv) == 1 else sys.argv[1]
13 | payload = {"q": letter}
14 |
15 | r = requests.post("http://0.0.0.0:5000/search_user", data=payload)
16 | try:
17 | response = r.json()
18 | if response == {}:
19 | print("No result")
20 | else:
21 | print("[{}] {}".format(response.get("id"), response.get("name")))
22 | except ValueError:
23 | print("Not a valid JSON")
24 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/5-main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | text_indentation = __import__('5-text_indentation').text_indentation
3 |
4 | text_indentation("""Lorem ipsum dolor sit amet, consectetur adipiscing elit. \
5 | Quonam modo? Utrum igitur tibi litteram videor an totas paginas commovere? \
6 | Non autem hoc: igitur ne illud quidem. Fortasse id optimum, sed ubi illud: \
7 | Plus semper voluptatis? Teneo, inquit, finem illi videri nihil dolere. \
8 | Transfer idem ad modestiam vel temperantiam, quae est moderatio cupiditatum \
9 | rationi oboediens. Si id dicis, vicimus. Inde sermone vario sex illa a Dipylo \
10 | stadia confecimus. Sin aliud quid voles, postea. Quae animi affectio suum \
11 | cuique tribuens atque hanc, quam dico. Utinam quidem dicerent alium alio \
12 | beatiorem! Iam ruinas videres""")
13 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/1-filter_states.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script lists all states with
4 | a `name` starting with the letter `N`
5 | from the database `hbtn_0e_0_usa`.
6 | """
7 |
8 | import MySQLdb as db
9 | from sys import argv
10 |
11 | """
12 | Access to the database and get the states
13 | from the database.
14 | """
15 |
16 | if __name__ == '__main__':
17 | db_connect = db.connect(host="localhost", port=3306,
18 | user=argv[1], passwd=argv[2], db=argv[3])
19 | db_cursor = db_connect.cursor()
20 |
21 | db_cursor.execute(
22 | "SELECT * FROM states WHERE name LIKE BINARY 'N%' \
23 | ORDER BY states.id ASC")
24 |
25 | rows_selected = db_cursor.fetchall()
26 |
27 | for row in rows_selected:
28 | print(row)
29 |
--------------------------------------------------------------------------------
/0x01-python-if_else_loops_functions/13-insert_number.c:
--------------------------------------------------------------------------------
1 | #include "lists.h"
2 |
3 | /**
4 | * insert_node - Inserts a number into a sorted singly-linked list.
5 | * @head: A pointer the head of the linked list.
6 | * @number: The number to insert.
7 | * Return: 0 If the function fails or pointer to the new node.
8 | */
9 | listint_t *insert_node(listint_t **head, int number)
10 | {
11 | listint_t *node = *head, *new;
12 |
13 | new = malloc(sizeof(listint_t));
14 | if (new == NULL)
15 | return (NULL);
16 | new->n = number;
17 |
18 | if (node == NULL || node->n >= number)
19 | {
20 | new->next = node;
21 | *head = new;
22 | return (new);
23 | }
24 |
25 | while (node && node->next && node->next->n < number)
26 | node = node->next;
27 |
28 | new->next = node->next;
29 | node->next = new;
30 |
31 | return (new);
32 | }
33 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/7-model_state_fetch_all.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script lists all State objects
4 | from the database `hbtn_0e_6_usa`.
5 | """
6 |
7 | from sys import argv
8 | from model_state import State, Base
9 | from sqlalchemy import create_engine
10 | from sqlalchemy.orm import sessionmaker
11 |
12 | if __name__ == "__main__":
13 | """
14 | Access to the database and get the states
15 | from the database.
16 | """
17 |
18 | db_url = "mysql+mysqldb://{}:{}@localhost:3306/{}".format(
19 | argv[1], argv[2], argv[3])
20 |
21 | engine = create_engine(db_url)
22 | Session = sessionmaker(bind=engine)
23 |
24 | session = Session()
25 |
26 | for instance in session.query(State).order_by(State.id):
27 | print('{0}: {1}'.format(instance.id, instance.name))
28 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/12-model_state_update_id_2.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script changes the name of a State object
4 | from the database `hbtn_0e_6_usa`.
5 | """
6 |
7 | from sys import argv
8 | from model_state import State, Base
9 | from sqlalchemy import create_engine
10 | from sqlalchemy.orm import sessionmaker
11 |
12 | if __name__ == "__main__":
13 | """
14 | Updates a State object on the database.
15 | """
16 |
17 | db_url = "mysql+mysqldb://{}:{}@localhost:3306/{}".format(
18 | argv[1], argv[2], argv[3])
19 |
20 | engine = create_engine(db_url)
21 | Session = sessionmaker(bind=engine)
22 |
23 | session = Session()
24 |
25 | state = session.query(State).filter(State.id == 2).first()
26 | state.name = "New Mexico"
27 | session.commit()
28 |
29 | session.close()
30 |
--------------------------------------------------------------------------------
/0x13-javascript_objects_scopes_closures/4-rectangle.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | /**
3 | * Check the parameters provided
4 | */
5 | class Rectangle {
6 | constructor (w, h) {
7 | if (typeof w === 'number' && w > 0 && typeof h === 'number' && h > 0) {
8 | this.width = w;
9 | this.height = h;
10 | }
11 | }
12 |
13 | print () {
14 | for (let i = 0; i < this.height; i++) {
15 | let myVar = '';
16 | let y = 0;
17 | while (y < this.width) {
18 | myVar += 'X';
19 | y++;
20 | }
21 |
22 | console.log(myVar);
23 | }
24 | }
25 |
26 | rotate () {
27 | let temp = 0;
28 | temp = this.width;
29 | this.width = this.height;
30 | this.height = temp;
31 | }
32 |
33 | double () {
34 | this.width *= 2;
35 | this.height *= 2;
36 | }
37 | }
38 | module.exports = Rectangle;
39 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/11-model_state_insert.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script adds the State object
4 | `Louisiana` to the database `hbtn_0e_6_usa`.
5 | """
6 |
7 | from sys import argv
8 | from model_state import State, Base
9 | from sqlalchemy import create_engine
10 | from sqlalchemy.orm import sessionmaker
11 |
12 | if __name__ == "__main__":
13 | """
14 | Access to the database and get a state
15 | from the database.
16 | """
17 |
18 | db_url = "mysql+mysqldb://{}:{}@localhost:3306/{}".format(
19 | argv[1], argv[2], argv[3])
20 |
21 | engine = create_engine(db_url)
22 | Session = sessionmaker(bind=engine)
23 |
24 | session = Session()
25 |
26 | new_state = State(name="Louisiana")
27 | session.add(new_state)
28 | session.commit()
29 |
30 | print('{0}'.format(new_state.id))
31 | session.close()
32 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/7-base_geometry.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a base geometry class BaseGeometry."""
3 |
4 |
5 | class BaseGeometry:
6 | """Reprsent base geometry."""
7 |
8 | def area(self):
9 | """Not yet implemented."""
10 | raise Exception("area() is not implemented")
11 |
12 | def integer_validator(self, name, value):
13 | """Validate a parameter as an integer.
14 | Args:
15 | name (str): The name of the parameter.
16 | value (int): The parameter to validate.
17 | Raises:
18 | TypeError: If value is not an integer.
19 | ValueError: If value is <= 0.
20 | """
21 | if type(value) != int:
22 | raise TypeError("{} must be an integer".format(name))
23 | if value <= 0:
24 | raise ValueError("{} must be greater than 0".format(name))
25 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/2-my_filter_states.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script takes in an argument and
4 | displays all values in the states
5 | where `name` matches the argument
6 | from the database `hbtn_0e_0_usa`.
7 | """
8 |
9 | import MySQLdb as db
10 | from sys import argv
11 |
12 | if __name__ == '__main__':
13 | """
14 | Access to the database and get the states
15 | from the database.
16 | """
17 | db_connect = db.connect(host="localhost", port=3306,
18 | user=argv[1], passwd=argv[2], db=argv[3])
19 | db_cursor = db_connect.cursor()
20 |
21 | db_cursor.execute(
22 | "SELECT * FROM states WHERE name LIKE BINARY '{}' ORDER BY \
23 | states.id ASC".format(argv[4]))
24 | rows_selected = db_cursor.fetchall()
25 |
26 | for row in rows_selected:
27 | print(row)
28 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/13-main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "lists.h"
4 |
5 | /**
6 | * main - check the code for
7 | *
8 | * Return: Always 0.
9 | */
10 | int main(void)
11 | {
12 | listint_t *head;
13 |
14 | head = NULL;
15 | add_nodeint_end(&head, 1);
16 | add_nodeint_end(&head, 17);
17 | add_nodeint_end(&head, 972);
18 | add_nodeint_end(&head, 50);
19 | add_nodeint_end(&head, 98);
20 | add_nodeint_end(&head, 98);
21 | add_nodeint_end(&head, 50);
22 | add_nodeint_end(&head, 972);
23 | add_nodeint_end(&head, 17);
24 | add_nodeint_end(&head, 1);
25 | print_listint(head);
26 |
27 | if (is_palindrome(&head) == 1)
28 | printf("Linked list is a palindrome\n");
29 | else
30 | printf("Linked list is not a palindrome\n");
31 |
32 | free_listint(head);
33 |
34 | return (0);
35 | }
36 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/10-model_state_my_get.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script prints the first State object
4 | from the database `hbtn_0e_6_usa`.
5 | """
6 |
7 | from sys import argv
8 | from model_state import State, Base
9 | from sqlalchemy import create_engine
10 | from sqlalchemy.orm import sessionmaker
11 |
12 | if __name__ == "__main__":
13 | """
14 | Access to the database and get a state
15 | from the database.
16 | """
17 |
18 | db_url = "mysql+mysqldb://{}:{}@localhost:3306/{}".format(
19 | argv[1], argv[2], argv[3])
20 |
21 | engine = create_engine(db_url)
22 | Session = sessionmaker(bind=engine)
23 |
24 | session = Session()
25 |
26 | state = session.query(State).filter(State.name == argv[4]).first()
27 | if state is not None:
28 | print('{0}'.format(state.id))
29 | else:
30 | print("Not found")
31 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/102-relationship_cities_states_list.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | Lists all City objects from the database hbtn_0e_101_usa
4 | """
5 | import sys
6 | from relationship_state import Base, State
7 | from relationship_city import City
8 | from sqlalchemy import create_engine
9 | from sqlalchemy.orm import sessionmaker
10 |
11 |
12 | if __name__ == '__main__':
13 | engine = create_engine('mysql+mysqldb://{}:{}@localhost:3306/{}'.
14 | format(sys.argv[1], sys.argv[2], sys.argv[3]),
15 | pool_pre_ping=True)
16 |
17 | Session = sessionmaker(bind=engine)
18 | session = Session()
19 |
20 | states = session.query(State).join(City).order_by(City.id).all()
21 |
22 | for state in states:
23 | for city in state.cities:
24 | print("{}: {} -> {}".format(city.id, city.name, state.name))
25 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/relationship_state.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script defines a State class and
4 | a Base class to work with MySQLAlchemy ORM.
5 | """
6 |
7 | from sqlalchemy import Column, Integer, String
8 | from sqlalchemy.orm import relationship
9 | from sqlalchemy.ext.declarative import declarative_base
10 |
11 | Base = declarative_base()
12 |
13 |
14 | class State(Base):
15 | """State class
16 | Attributes:
17 | __tablename__ (str): The table name of the class
18 | id (int): The State id of the class
19 | name (str): The State name of the class
20 | cities (:obj:`City`): The Cities belongs to State
21 | """
22 | __tablename__ = 'states'
23 |
24 | id = Column(Integer, primary_key=True)
25 | name = Column(String(128), nullable=False)
26 | cities = relationship("City", backref="state", cascade="all, delete")
27 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/4-print_square.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This module contain a function that prints a square
4 | """
5 |
6 |
7 | def print_square(size):
8 | """This function prints a square with the character #
9 | Args:
10 | size (int): This represents the length of the square
11 | Raises:
12 | TypeError: If size is not an integer
13 | TypeError: If size is a float and less than zero
14 | ValueError: If size is less than zero
15 | """
16 |
17 | if not isinstance(size, int):
18 | raise TypeError("size must be an integer")
19 | elif size < 0:
20 | raise ValueError("size must be >= 0")
21 | elif isinstance(size, float) and size < 0:
22 | raise TypeError("size must be an integer")
23 | for n in range(0, size):
24 | for m in range(size):
25 | print("#", end="")
26 | print("")
27 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/8-model_state_fetch_first.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script prints the first State object
4 | from the database `hbtn_0e_6_usa`.
5 | """
6 |
7 | from sys import argv
8 | from model_state import State, Base
9 | from sqlalchemy import create_engine
10 | from sqlalchemy.orm import sessionmaker
11 |
12 | if __name__ == "__main__":
13 | """
14 | Access to the database and get a state
15 | from the database.
16 | """
17 |
18 | db_url = "mysql+mysqldb://{}:{}@localhost:3306/{}".format(
19 | argv[1], argv[2], argv[3])
20 |
21 | engine = create_engine(db_url)
22 | Session = sessionmaker(bind=engine)
23 |
24 | session = Session()
25 |
26 | state = session.query(State).order_by(State.id).first()
27 | if state is not None:
28 | print('{0}: {1}'.format(state.id, state.name))
29 | else:
30 | print("Nothing")
31 |
--------------------------------------------------------------------------------
/0x06-python-classes/3-square.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # 0-square.py by UDO INNOCENT
3 | """A module that defines a square """
4 |
5 |
6 | class Square:
7 | """A class that represents a square"""
8 |
9 | def __init__(self, size=0):
10 | """Initializing this square class
11 | Args:
12 | size: represnets the size of the square defined
13 | Raises:
14 | TypeError: if size is not integer
15 | ValueError: if size is less than zero
16 | """
17 |
18 | if not isinstance(size, int):
19 | raise TypeError('size must be an integer')
20 | if size < 0:
21 | raise ValueError('size must be >= 0')
22 |
23 | self.__size = size
24 |
25 | def area(self):
26 | """
27 | Calculate area of the square
28 | Returns: The square of the size
29 | """
30 |
31 | return (self.__size ** 2)
32 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/4-cities_by_state.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script lists all cities from
4 | the database `hbtn_0e_4_usa`.
5 | """
6 |
7 | import MySQLdb as db
8 | from sys import argv
9 |
10 | if __name__ == '__main__':
11 | """
12 | Access the database and get the cities
13 | from the database.
14 | """
15 |
16 | db_connect = db.connect(host="localhost", port=3306,
17 | user=argv[1], passwd=argv[2], db=argv[3])
18 |
19 | with db_connect.cursor() as db_cursor:
20 | db_cursor.execute("SELECT cities.id, cities.name, states.name \
21 | FROM cities JOIN states ON cities.state_id \
22 | = states.id ORDER BY cities.id ASC")
23 | rows_selected = db_cursor.fetchall()
24 |
25 | if rows_selected is not None:
26 | for row in rows_selected:
27 | print(row)
28 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/9-model_state_filter_a.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script lists all State objects
4 | that contain the letter `a`
5 | from the database `hbtn_0e_6_usa`.
6 | """
7 |
8 | from sys import argv
9 | from model_state import State, Base
10 | from sqlalchemy import create_engine
11 | from sqlalchemy.orm import sessionmaker
12 |
13 | if __name__ == "__main__":
14 | """
15 | Access to the database and get a state
16 | from the database.
17 | """
18 |
19 | db_url = "mysql+mysqldb://{}:{}@localhost:3306/{}".format(
20 | argv[1], argv[2], argv[3])
21 |
22 | engine = create_engine(db_url)
23 | Session = sessionmaker(bind=engine)
24 |
25 | session = Session()
26 |
27 | states = session.query(State).filter(State.name.contains('a'))
28 | if states is not None:
29 | for state in states:
30 | print('{0}: {1}'.format(state.id, state.name))
31 |
--------------------------------------------------------------------------------
/0x05-python-exceptions/4-list_division.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def list_division(my_list_1, my_list_2, list_length):
3 | """Divides two lists element by element.
4 | Args:
5 | my_list_1 (list): The first list.
6 | my_list_2 (list): The second list.
7 | list_length (int): The number of elements to divide.
8 | Returns:
9 | A new list of length list_length containing all the divisions.
10 | """
11 | new_list = []
12 | for i in range(0, list_length):
13 | try:
14 | div = my_list_1[i] / my_list_2[i]
15 | except TypeError:
16 | print("wrong type")
17 | div = 0
18 | except ZeroDivisionError:
19 | print("division by 0")
20 | div = 0
21 | except IndexError:
22 | print("out of range")
23 | div = 0
24 | finally:
25 | new_list.append(div)
26 | return (new_list)
27 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/13-model_state_delete_a.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script deletes all State objects
4 | with a name containing the letter `a`
5 | from the database `hbtn_0e_6_usa`.
6 | """
7 |
8 | from sys import argv
9 | from model_state import State, Base
10 | from sqlalchemy import create_engine
11 | from sqlalchemy.orm import sessionmaker
12 |
13 | if __name__ == "__main__":
14 | """
15 | Deletes State objects on the database.
16 | """
17 |
18 | db_url = "mysql+mysqldb://{}:{}@localhost:3306/{}".format(
19 | argv[1], argv[2], argv[3])
20 |
21 | engine = create_engine(db_url)
22 | Session = sessionmaker(bind=engine)
23 |
24 | session = Session()
25 |
26 | states = session.query(State).filter(State.name.contains('a'))
27 | if states is not None:
28 | for state in states:
29 | session.delete(state)
30 |
31 | session.commit()
32 |
33 | session.close()
34 |
--------------------------------------------------------------------------------
/0x0A-python-inheritance/9-rectangle.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """WAP that defines a class Rectangle that inherits from BaseGeometry."""
3 | BaseGeometry = __import__('7-base_geometry').BaseGeometry
4 |
5 |
6 | class Rectangle(BaseGeometry):
7 | """Represents a rectangle using BaseGeometry"""
8 |
9 | def __init__(self, width, height):
10 | """Intialize a new rectangle"""
11 |
12 | super().integer_validator("width", width)
13 | self.__width = width
14 | super().integer_validator("height", height)
15 | self.__height = height
16 |
17 | def area(self):
18 | """returns the area of the rectangle"""
19 | return self.__width * self.__height
20 |
21 | def __str__(self):
22 | """returns the print() and str() representation of a Rectangle"""
23 | string = "[" + str(self.__class__.__name__) + "] "
24 | string += str(self.__width) + "/" + str(self.__height)
25 | return string
26 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/3-my_safe_filter_states.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script takes in an argument and
4 | displays all values in the states
5 | where `name` matches the argument
6 | from the database `hbtn_0e_0_usa`.
7 | This time the script is safe from
8 | MySQL injections!
9 | """
10 |
11 | import MySQLdb as db
12 | from sys import argv
13 |
14 | if __name__ == "__main__":
15 | """
16 | Access to the database and get the states
17 | from the database.
18 | """
19 | db_connect = db.connect(host="localhost", port=3306,
20 | user=argv[1], passwd=argv[2], db=argv[3])
21 |
22 | db_cursor = db_connect.cursor()
23 | db_cursor.execute(
24 | "SELECT * FROM states WHERE name LIKE \
25 | BINARY %(name)s ORDER BY states.id ASC", {'name': argv[4]})
26 |
27 | rows_selected = db_cursor.fetchall()
28 |
29 | for row in rows_selected:
30 | print(row)
31 |
--------------------------------------------------------------------------------
/0x02-python-import_modules/calculator_1.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | def add(a, b):
3 | """My addition function
4 | Args:
5 | a: first integer
6 | b: second integer
7 | Returns:
8 | The return value. a + b
9 | """
10 | return (a + b)
11 |
12 |
13 | def sub(a, b):
14 | """My subtraction function
15 | Args:
16 | a: first integer
17 | b: second integer
18 | Returns:
19 | The return value. a - b
20 | """
21 | return (a - b)
22 |
23 |
24 | def mul(a, b):
25 | """My multiplication function
26 | Args:
27 | a: first integer
28 | b: second integer
29 | Returns:
30 | The return value. a * b
31 | """
32 | return (a * b)
33 |
34 |
35 | def div(a, b):
36 | """My division function
37 | Args:
38 | a: first integer
39 | b: second integer
40 | Returns:
41 | The return value. a / b
42 | """
43 | return int(a / b)
44 |
--------------------------------------------------------------------------------
/0x10-python-network_0/6-peak.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """ Finds a peak in a list of unsorted integers
3 | """
4 |
5 |
6 | def find_peak(list_of_integers):
7 | """
8 | Args:
9 | list_of_integers(int): list of integers to find peak of
10 | Returns: peak of list_of_integers or None
11 | """
12 | size = len(list_of_integers)
13 | mid_e = size
14 | mid = size // 2
15 |
16 | if size == 0:
17 | return None
18 |
19 | while True:
20 | mid_e = mid_e // 2
21 | if (mid < size - 1 and
22 | list_of_integers[mid] < list_of_integers[mid + 1]):
23 | if mid_e // 2 == 0:
24 | mid_e = 2
25 | mid = mid + mid_e // 2
26 | elif mid_e > 0 and list_of_integers[mid] < list_of_integers[mid - 1]:
27 | if mid_e // 2 == 0:
28 | mid_e = 2
29 | mid = mid - mid_e // 2
30 | else:
31 | return list_of_integers[mid]
32 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/11-student.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a class Student"""
3 |
4 |
5 | class Student:
6 | """Represent a student."""
7 |
8 | def __init__(self, first_name, last_name, age):
9 | """Initializes a new Student"""
10 | self.first_name = first_name
11 | self.last_name = last_name
12 | self.age = age
13 |
14 | def to_json(self, attrs=None):
15 | """Gets a dictionary representation of the Student.
16 | If attrs is a list of strings, represents only those attributes
17 | included in the list"""
18 | if (type(attrs) == list and
19 | all(type(ele) == str for ele in attrs)):
20 | return {k: getattr(self, k) for k in attrs if hasattr(self, k)}
21 | return self.__dict__
22 |
23 | def reload_from_json(self, json):
24 | """Replaces all attributes of the Student"""
25 | for k, v in json.items():
26 | setattr(self, k, v)
27 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/14-model_city_fetch_by_state.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script prints all City objects
4 | from the database `hbtn_0e_14_usa`.
5 | """
6 |
7 | from sys import argv
8 | from model_state import State, Base
9 | from model_city import City
10 | from sqlalchemy import create_engine
11 | from sqlalchemy.orm import sessionmaker
12 |
13 | if __name__ == "__main__":
14 | """
15 | Access to the database and get the cities
16 | from the database.
17 | """
18 |
19 | db_url = "mysql+mysqldb://{}:{}@localhost:3306/{}".format(
20 | argv[1], argv[2], argv[3])
21 |
22 | engine = create_engine(db_url)
23 | Session = sessionmaker(bind=engine)
24 |
25 | session = Session()
26 |
27 | results = session.query(City, State).join(State)
28 |
29 | for city, state in results.all():
30 | print("{}: ({}) {}".format(state.name, city.id, city.name))
31 |
32 | session.commit()
33 | session.close()
34 |
--------------------------------------------------------------------------------
/0x10-python-network_0/README.md:
--------------------------------------------------------------------------------
1 | # Python - Network #0
2 |
3 | 
4 |
5 | ## Learning Objectives
6 |
7 | - What a URL is
8 | - What HTTP is
9 | - How to read a URL
10 | - The scheme for a HTTP URL
11 | - What a domain name is
12 | - What a sub-domain is
13 | - How to define a port number in a URL
14 | - What a query string is
15 | - What an HTTP request is
16 | - What an HTTP response is
17 | - What HTTP headers are
18 | - What the HTTP message body is
19 | - What an HTTP request method is
20 | - What an HTTP response status code is
21 | - What an HTTP Cookie is
22 | - How to make a request with cURL
23 | - What happens when you type google.com in your browser (Application level)
24 |
25 | ## Needed Knowledge
26 |
27 | - HTTP (HyperText Transfer Protocol) (except: “TRACE” Request Method, “CONNECT” Request Method, Language Negotiation and “Options MultiView” and Character Set Negotiation)
28 | - HTTP Cookies
29 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/100-relationship_states_cities.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script prints all City objects
4 | from the database `hbtn_0e_14_usa`.
5 | """
6 |
7 | from sys import argv
8 | from relationship_state import Base, State
9 | from relationship_city import City
10 | from sqlalchemy import create_engine
11 | from sqlalchemy.orm import sessionmaker
12 |
13 | if __name__ == "__main__":
14 | """
15 | Access to the database and get the cities
16 | from the database.
17 | """
18 |
19 | db_uri = 'mysql+mysqldb://{}:{}@localhost:3306/{}'.format(
20 | argv[1], argv[2], argv[3])
21 | engine = create_engine(db_uri)
22 | Base.metadata.create_all(engine)
23 | Session = sessionmaker(bind=engine)
24 |
25 | session = Session()
26 | cal_state = State(name='California')
27 | sfr_city = City(name='San Francisco')
28 | cal_state.cities.append(sfr_city)
29 |
30 | session.add(cal_state)
31 | session.commit()
32 | session.close()
33 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/101-relationship_states_cities_list.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | Lists all State objects and corresponding City objects contained in the DB
4 | """
5 | import sys
6 | from relationship_state import Base, State
7 | from relationship_city import City
8 | from sqlalchemy import create_engine
9 | from sqlalchemy.orm import sessionmaker
10 |
11 |
12 | if __name__ == '__main__':
13 | engine = create_engine('mysql+mysqldb://{}:{}@localhost:3306/{}'.
14 | format(sys.argv[1], sys.argv[2], sys.argv[3]),
15 | pool_pre_ping=True)
16 | Base.metadata.create_all(engine)
17 |
18 | Session = sessionmaker(bind=engine)
19 | session = Session()
20 |
21 | st = session.query(State).outerjoin(City).order_by(State.id, City.id).all()
22 |
23 | for state in st:
24 | print("{}: {}".format(state.id, state.name))
25 | for city in state.cities:
26 | print(" {}: {}".format(city.id, city.name))
27 |
--------------------------------------------------------------------------------
/0x07-python-test_driven_development/5-text_indentation.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This module contains a function that indents texts
4 | """
5 |
6 |
7 | def text_indentation(text):
8 | '''This function prints a text with 2 new lines after each ".", "?", or ":"
9 | Args:
10 | text (str): The string to be printed
11 | Raises:
12 | TypeError: If text is not a string
13 | '''
14 |
15 | if not isinstance(text, str):
16 | raise TypeError("text must be a string")
17 |
18 | count = 0
19 | while count < len(text) and text[count] == " ":
20 | count = count + 1
21 |
22 | while count < len(text):
23 | print(text[count], end="")
24 | if text[count] == "\n" or text[count] in ".?:":
25 | if text[count] in ".?:":
26 | print("\n")
27 | count = count + 1
28 | while count < len(text) and text[count] == " ":
29 | count = count + 1
30 | continue
31 | count = count + 1
32 |
--------------------------------------------------------------------------------
/0x0B-python-input_output/10-student.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """Defines a class Student."""
3 |
4 |
5 | class Student:
6 | """Represent a student."""
7 |
8 | def __init__(self, first_name, last_name, age):
9 | """Initialize a new Student.
10 | Args:
11 | first_name (str): The first name of the student.
12 | last_name (str): The last name of the student.
13 | age (int): The age of the student.
14 | """
15 | self.first_name = first_name
16 | self.last_name = last_name
17 | self.age = age
18 |
19 | def to_json(self, attrs=None):
20 | """Get a dictionary representation of the Student.
21 | If attrs is a list of strings, represents only those attributes
22 | included in the list.
23 | Args:
24 | attrs (list): (Optional) The attributes to represent.
25 | """
26 | if (type(attrs) == list and
27 | all(type(ele) == str for ele in attrs)):
28 | return {k: getattr(self, k) for k in attrs if hasattr(self, k)}
29 | return self.__dict__
30 |
--------------------------------------------------------------------------------
/0x0F-python-object_relational_mapping/5-filter_cities.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | This script takes in the name of a state
4 | as an argument and lists all cities of that
5 | state, using the database `hbtn_0e_4_usa`.
6 | """
7 |
8 | import MySQLdb as db
9 | from sys import argv
10 |
11 | if __name__ == "__main__":
12 | """
13 | Access to the database and get the cities
14 | from the database.
15 | """
16 |
17 | db_connect = db.connect(host="localhost", port=3306,
18 | user=argv[1], passwd=argv[2], db=argv[3])
19 |
20 | with db_connect.cursor() as db_cursor:
21 | db_cursor.execute("""
22 | SELECT
23 | cities.id, cities.name
24 | FROM
25 | cities
26 | JOIN
27 | states
28 | ON
29 | cities.state_id = states.id
30 | WHERE
31 | states.name LIKE BINARY %(state_name)s
32 | ORDER BY
33 | cities.id ASC
34 | """, {
35 | 'state_name': argv[4]
36 | })
37 | rows_selected = db_cursor.fetchall()
38 |
39 | if rows_selected is not None:
40 | print(", ".join([row[1] for row in rows_selected]))
41 |
--------------------------------------------------------------------------------
/0x06-python-classes/4-square.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # 0-square.py by UDO INNOCENT
3 | """A module that defines a square """
4 |
5 |
6 | class Square:
7 | """A class that represents a square"""
8 |
9 | def __init__(self, size=0):
10 | """Initializing this square class
11 | Args:
12 | size: represnets the size of the square defined
13 | Raises:
14 | TypeError: if size is not integer
15 | ValueError: if size is less than zero
16 | """
17 |
18 | if not isinstance(size, int):
19 | raise TypeError('size must be an integer')
20 | if size < 0:
21 | raise ValueError('size must be >= 0')
22 |
23 | self.__size = size
24 |
25 | @property
26 | def size(self):
27 | """Retrieves size of square"""
28 |
29 | return self.__size
30 |
31 | @size.setter
32 | def size(self, value):
33 | if not isinstance(value, int):
34 | raise TypeError('size must be an integer')
35 | if value < 0:
36 | raise ValueError('size must be >= 0')
37 | self.__size = value
38 |
39 | def area(self):
40 | """
41 | Calculate area of the square
42 | Returns: The square of the size
43 | """
44 |
45 | return (self.__size ** 2)
46 |
--------------------------------------------------------------------------------
/0x11-python-network_1/100-github_commits.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | """
3 | Module to access to the GitHub API and uses the information
4 | """
5 | import requests
6 | from requests.auth import HTTPBasicAuth
7 | from sys import argv
8 |
9 |
10 | def main(argv):
11 | """
12 | Function that list 10 commits (from the most recent to oldest)
13 | of the repository.The first argument will be the repository name
14 | and the second argument will be the owner name
15 | """
16 |
17 | def print_commits(i, commit_list):
18 | """
19 | List the commits, less than 10 commits
20 | """
21 | sha = commit_list[i].get('sha')
22 | commit = commit_list[i].get('commit')
23 | author = commit.get('author')
24 | name = author.get('name')
25 | print('{}: {}'.format(sha, name))
26 |
27 | repo = argv[1]
28 | owner = argv[2]
29 | headers = {"Accept": "application/vnd.github.v3+json"}
30 | response = requests.get('https://api.github.com/repos/' + owner +
31 | '/' + repo + '/commits', headers=headers)
32 | commit_list = response.json()
33 | size = len(commit_list)
34 | if size < 10:
35 | for i in range(0, size):
36 | print_commits(i, commit_list)
37 | else:
38 | for i in range(0, 10):
39 | print_commits(i, commit_list)
40 |
41 |
42 | if __name__ == "__main__":
43 | main(argv)
44 |
--------------------------------------------------------------------------------
/0x03-python-data_structures/13-is_palindrome.c:
--------------------------------------------------------------------------------
1 | #include "lists.h"
2 |
3 | /**
4 | * reverse_listint - reverses a linked list
5 | * @head: pointer to the first node in the list
6 | * Return: pointer to the first node in the new list
7 | */
8 | void reverse_listint(listint_t **head)
9 | {
10 | listint_t *prev = NULL;
11 | listint_t *current = *head;
12 | listint_t *next = NULL;
13 |
14 | while (current)
15 | {
16 | next = current->next;
17 | current->next = prev;
18 | prev = current;
19 | current = next;
20 | }
21 |
22 | *head = prev;
23 | }
24 |
25 | /**
26 | * is_palindrome - checks if a linked list is a palindrome
27 | * @head: double pointer to the linked list
28 | *
29 | * Return: 1 if it is, 0 if not
30 | */
31 | int is_palindrome(listint_t **head)
32 | {
33 | listint_t *slow = *head, *fast = *head, *temp = *head, *dup = NULL;
34 |
35 | if (*head == NULL || (*head)->next == NULL)
36 | return (1);
37 |
38 | while (1)
39 | {
40 | fast = fast->next->next;
41 | if (!fast)
42 | {
43 | dup = slow->next;
44 | break;
45 | }
46 | if (!fast->next)
47 | {
48 | dup = slow->next->next;
49 | break;
50 | }
51 | slow = slow->next;
52 | }
53 |
54 | reverse_listint(&dup);
55 |
56 | while (dup && temp)
57 | {
58 | if (temp->n == dup->n)
59 | {
60 | dup = dup->next;
61 | temp = temp->next;
62 | }
63 | else
64 | return (0);
65 | }
66 |
67 | if (!dup)
68 | return (1);
69 |
70 | return (0);
71 | }
72 |
--------------------------------------------------------------------------------