diff --git a/Day 2/variables.py b/Day 2/variables.py new file mode 100644 index 000000000..d0dc01361 --- /dev/null +++ b/Day 2/variables.py @@ -0,0 +1,62 @@ +# Day 2: 30 Days of python programming +# ! Level 1 +first_name = "Ahmad" +last_name = "Al-Sanosi" +full_name = first_name + " " + last_name +country = "Sudan" +city = "Khartoum" +age = 21 +year = 2003 +is_married = False +is_true = True +is_light_on = False +street_num, building_num, room_num = 4, 21, 623 + +# ! Level 2 +print(f"The data type of {first_name} is {type(first_name)}") +print(f"The data type of {last_name} is {type(last_name)}") +print(f"The data type of {full_name} is {type(full_name)}") +print(f"The data type of {country} is {type(country)}") +print(f"The data type of {city} is {type(city)}") +print(f"The data type of {age} is {type(age)}") +print(f"The data type of {year} is {type(year)}") +print(f"The data type of {is_married} is {type(is_married)}") +print(f"The data type of {is_light_on} is {type(is_light_on)}") +print(f"The data type of {street_num} is {type(street_num)}") +print(f"The data type of {building_num} is {type(building_num)}") +print(f"The data type of {room_num} is {type(room_num)}") + +print(f"The length of {first_name} is {len(first_name)} while the length of the {last_name} is {len(last_name)}") + +num_one = 5 +num_two = 4 +total = num_one + num_two +diff = num_one - num_two +product = num_one * num_two +division = num_one / num_two +remainder = num_two % num_one +exp = num_one ** num_two +floor_division = num_one // num_two +print(f"we have two numbers {num_one} and {num_two}") +print(f"The sum of {num_one} plus {num_two} equals {total}") +print(f"The difference of {num_one} minus {num_two} equals {diff}") +print(f"The product of {num_one} times {num_two} equals {product}") +print(f"The quotient of {num_one} over {num_two} equals {division}") +print(f"The remainder when dividing {num_two} by {num_one} is {remainder}") +print(f"The product of raising {num_one} to the power of {num_two} equals {exp}") +print(f"The floor division of {num_one} by {num_two} equals {floor_division}") + +radius_string = input('Enter a radius of a circle: ') +radius = int(radius_string) +area_of_circle = 3.14 * (radius ** 2) +circum_of_circle = 2 * 3.14 * radius +print(f"""The area of a circle of radius {radius} meters is equal to {area_of_circle} +and the circumference of that circle equals {circum_of_circle}""") + +first_name = input('Enter your first name :') +last_name = input('Enter your last name :') +country = input('Enter your country :') +age = input('Enter your age :') + + + diff --git a/Day 3/Day 3 Exercises.py b/Day 3/Day 3 Exercises.py new file mode 100644 index 000000000..60cf7493a --- /dev/null +++ b/Day 3/Day 3 Exercises.py @@ -0,0 +1,94 @@ +your_age = 28 +your_height = 191.5 +imaginary = 32 + 4j +print(f"type of your_age is {type(your_age)}") +print('type of your_height is', type(your_height)) + +################################################## + +script_base = input('Enter the base of a triangle: ') +base = float(script_base) +script_height = input('Enter the height of that triangle: ') +height = float(script_height) +print(f"The area of the triangle equals {round(0.5 * base * height, 2)}") + +side_a = input('Enter side a of a triangle: ') +a = float(side_a) +side_b = input('Enter side b of a triangle: ') +b = float(side_b) +side_c = input('Enter side c of a triangle: ') +c = float(side_c) +print('The perimeter of the triangle is ', a + b + c) + +script_length = input('Enter the length of a rectangle: '); length = float(script_length) +script_width = input('Enter the width of that rectangle: '); width = float(script_width) +print(f"The area of the rectangle equals {round(length * width, 2)}, and the perimeter of that rectangle equals {round(2*(length + width), 2)}") + +script_radius = input('Enter the radius of a circle: ') +radius = float(script_radius) +print('The area of the circle equals ', round(3.14 * radius**2, 2), ', and the circumference of that circle equals ', round(2*3.14*radius, 2)) + +##################################################### + +script_slope = input('Enter the value of the slope of a line:' ); slope = int(script_slope) +script_b = input('Enter the value of the free term of the line (If none, enter 0): '); b = int(script_b) +print(f"The equation of the line you entered is y = {slope}x + ({b})") +print(f"The slope of the equation equals {slope}. The x-intercept equals {-(b)/slope} and the y-intercept equals {b}") + +##################################################### + +print("Let's point out two points on the x-y plane!") +script_x1 = input('Enter the x-coordinate of the first point: '); x1 = int(script_x1) +script_y1 = input('Enter the y-coordinate of the first point: '); y1 = int(script_y1) +script_x2 = input('Enter the x-coordinate of the second point: '); x2 = int(script_x2) +script_y2 = input('Enter the y-coordinate of the second point: '); y2 = int(script_y2) +slope2 = round((y2-y1)/(x2-x1),2) +print(f"You've just entered the line equation: ({slope2})x + ({round((y1 - slope2*x1),2)})") +print(f"The euclidean distance between the points ({x1},{y1}) and ({x2},{y2}) equals {round(((y2-y1)**2+(x2-x1)**2)**0.5,2)}") + +######################################################## + +print('I challenge you to solve this problem.\n Find the x value that makes this equation equals 0 (You have only one trial)') +print('y = x^2 + 6x + 9') +script_user_answer = input('Enter your value for x in integers only: '); user_answer = int(script_user_answer) +if user_answer == -3 : print('Congratulations! Your answer is correct.') +else : print('Sorry. That was incorrect :/') + +######################################################### + +print('python is longer than dragon is a ', len('python') > len('dragon'), 'statement.') +print(f"The 'on' word exists on both python and dragon is a {'on' in 'python' and 'on' in 'dragon'} statement.") +print(f"there's jargon in 'I hope this course is not full of jargon' is a {'jargon' in 'I hope this course is not full of jargon'} statement.") +print(f"There's no 'on' in both dragon and python is a {'on' not in 'dragon' and 'on' not in 'python'} statement.") +print(f"The length of the word 'python' equals {len('python')}: {float(len('python'))}: {str(len('python'))}") + +########################################################## + +string_number = input("Enter an integer and I'll tell it's even or odd: "); number = int(string_number) +if number % 2 == 0 : print('Number is even') +else : print('Number is odd') + +########################################################## + +print(f"'The floor division of 7 by 3 is equal to the int converted value of 2.7' is a {7 // 3 == int(2.7)} statement.") +print(f"The type of '10' is equal to type of 10 is a {'10' is 10} statement.") +print(f"int('9.8') is equal to 10 is a {int(9.8) == 10} statement.") + +########################################################## + +string_hours = input('Enter the number of hours: '); hours = int(string_hours) +string_rph = input('Enter the rate per hour: '); rph = int(string_rph) +print(f"Your weekly earning is about {hours * rph}") + +########################################################## + +age = int(input('Enter your age: ')) +print('You have lived for ', age * 365 * 24 * 60 * 60, 'seconds.') + +########################################################## + +print('1 1 1 1 1 \n2 1 2 4 8 \n3 1 3 9 27 \n4 1 4 16 64 \n5 1 5 25 125 ') + + + + diff --git a/Day 4/Day 4 Exercises.py b/Day 4/Day 4 Exercises.py new file mode 100644 index 000000000..a8a34ffa6 --- /dev/null +++ b/Day 4/Day 4 Exercises.py @@ -0,0 +1,143 @@ +#1 +Thirty = 'Thirty' +Days = 'Days' +Of = 'of' +Python = 'Python' +print(Thirty + ' ' + Days + ' ' + Of + ' ' + Python) + +#2 +Coding = 'Coding' +_For = ' For' +All = ' All' +print(Coding + _For + All) + +#3, 4, 5, 6, 7, 8, 9 +company = 'Coding For All' +print(company) +print(f"length of Coding For All is {len(company)}") +print(company.upper()) +print(company.lower()) +print(f""" + Preview of several methods and their effects: + .capitalize() > {company.capitalize()} + .title() > {company.title()} + .swapcase() > {company.swapcase()} + """) +company_first_word = company[0:6] +print(f"First word of {company} is ({company_first_word})") + +#10 +company_check = company.find('Coding') != -1 +company_ans = f'"{company} contains the word {company_first_word}" is a {company_check} statement.' +company_ans_lowercase = company_ans.lower() +print(company_ans_lowercase) + +#11 +company_replace = company.replace('Coding', 'Python') +print(company_replace) + +#12 +python_all = 'Python For Everyone' +print(python_all.replace('Everyone', 'All')) + +#13 +company_split = company.split('*') +print(company_split) + +#14 +brands = "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon" +brands_split = brands.split(', ') +print(brands_split) + +#15 +print(f"The character at index 0 in the string '{company}' is '{company[0:1]}'") + +#16 +print(f'The last index of the string "{company}" is {company.rfind('l')}') + +#17 +print(f"The character at index 10 in '{company}' is '{company[10:11]}'") + +#18 +company_acronym1 = company[0:1] +company_acronym2 = company[7:8] +company_acronym3 = company[11:12] +print(company_acronym1+company_acronym2+company_acronym3) + +#19 +python_all_acronym1 = python_all[0:1] +python_all_acronym2 = python_all[7:8] +python_all_acronym3 = python_all[11:12] +print(python_all_acronym1+python_all_acronym2+python_all_acronym3) + +#20 +print(f'The index of the first occurence of C in {company} is {company.index('C')}') + +#21 +print(f'The index of the first occurence of F in {company} is {company.index('F')}') + +#22 +people = 'Coding For All People' +print(f'The index of the last occurence of l in {people} is {people.rfind('l')}') + +#23 +conjuction = 'You cannot end a sentence with because because because is a conjunction' +print(f'The index of the first occurence of "because" in "{conjuction}" is {conjuction.find('because')}') + +#24 +print(f'The index of the last occurence of "because" in "{conjuction}" is {conjuction.rindex('because')}') + +#25 +#? conjuction_sliced = conjuction[31:54] +#? print(conjuction_sliced) +#! TO AMMAR: Do I need to put everything into a variable? +print(conjuction[31:54]) + +#26 +print(f'The index of the first occurence of "because" in "{conjuction}" is {conjuction.find('because')}') + +#27 +print(conjuction[31:54]) + +#28 +coding_start = company.startswith('Coding') +coding_end = company.endswith('Coding') +print(company) +print(f'"{company} starts with the word {company_first_word}" is a {str(coding_start).lower()} statement.') + +#29 +print(f'"{company} ends with the word {company_first_word}" is a {str(coding_end).lower()} statement.') + +#30 +company_space = ' Coding For All ' +company_space_stripped = company_space.strip(' ') +print(company_space_stripped) + +#31 +isidentifier1 = '30DaysOfPython' +isidentifier2 = 'thirty_days_of_python' +print(f'"{isidentifier1} is a {str(isidentifier1).isidentifier()} identifier.') +print(f'"{isidentifier1} is a {str(isidentifier2).isidentifier()} identifier.') + +#32 +list1 = ['Django', 'Flask', 'Bottle', 'Pyramid', 'Falcon'] +print('# '.join(list1)) + +#33 +escape = 'I am enjoying this challenge. I just wonder what is next.' +# 0123456789 +escape_slice1 = escape[0:29] +escape_slice2 = escape[30:] +print(escape_slice1 + '\n' + escape_slice2) + +#34 +print('Name\t\tAge\t\tCountry\t\tCity') +print('Asabeneh\t250\t\tFinland\t\tHelsinki') + +#35 +radius = 10 +area = 3.14 * radius ** 2 +print('The area of a circle with radius {} is {} meters square.'.format(radius, area)) + +#36 +print('8 + 6 = {}\n8 - 6 = {}\n8 * 6 = {}\n8 / 6 = {}\n8 % 6 = {}\n8 // 6 = {}\n8 ** 6 = {}'.format(8+6, 8-6, 8*6, round(8/6, 1), 8%6, 8//6, 8**6)) \ No newline at end of file diff --git a/Day 4/Day 4 Notes.md b/Day 4/Day 4 Notes.md new file mode 100644 index 000000000..45df232fd --- /dev/null +++ b/Day 4/Day 4 Notes.md @@ -0,0 +1,34 @@ + +```py +sentence = "A\tB" +print(sentence) +print(len(sentence)) +expanded_tab = sentence.expandtabs(8) +print(expanded_tab) +``` + + +> [!NOTE] Note about .expandtabs( ) +> number in parents( ) will be executed with a value less than it by one + + +```py +name = input("Enter your name") +if name.isalpha(): + print("Thanks") +else: + print('invalid') +``` + +___ + +```py +#* Join + +name = "Ahmed Ammar Sanosi" +#* 01234567890 +#* 0 1 2 + +# [] +``` +![[Pasted image 20250705091203.png]] \ No newline at end of file diff --git a/Day 4/Note1.png b/Day 4/Note1.png new file mode 100644 index 000000000..f88d2bb91 Binary files /dev/null and b/Day 4/Note1.png differ diff --git a/Day 4/Pasted image 20250705091203.png b/Day 4/Pasted image 20250705091203.png new file mode 100644 index 000000000..44410ac9a Binary files /dev/null and b/Day 4/Pasted image 20250705091203.png differ diff --git a/Day 5/Day_05_Exercises.ipynb b/Day 5/Day_05_Exercises.ipynb new file mode 100644 index 000000000..25144126b --- /dev/null +++ b/Day 5/Day_05_Exercises.ipynb @@ -0,0 +1,721 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 62, + "id": "eb50d4c0", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The length of six_items is 6\n", + "item1 item2 item6\n" + ] + } + ], + "source": [ + "# Declare an empty list\n", + "\n", + "# Declare a list with more than 5 items\n", + "\n", + "# Find the length of your list\n", + "\n", + "# Get the first item, the middle item and the last item of the list\n", + "\n", + "six_items = [\"item1\", \"item2\", \"item3\", \"item4\", \"item5\", \"item6\"] #2\n", + "print(f\"The length of six_items is {len(six_items)}\") #3\n", + "print(six_items[0], six_items[1], six_items[-1]) #4" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "id": "8fc27819", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "item1\n", + "item6\n", + "item3\n" + ] + } + ], + "source": [ + "first_item = six_items[0]\n", + "\n", + "last_item = six_items[-1]\n", + "if len(six_items) % 2 == 0:\n", + " middle_item_indx = round(len(six_items) / 2) - 1 \n", + "else: \n", + " middle_item_indx = round(len(six_items) / 2)\n", + "\n", + "\n", + "middle_item = six_items[middle_item_indx]\n", + "\n", + "print(first_item)\n", + "print(last_item)\n", + "print(middle_item)" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "09cb9bc7", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "item4\n" + ] + } + ], + "source": [ + "import random\n", + "\n", + "idx = random.randint(0, len(six_items) -1)\n", + "\n", + "print(six_items[idx])" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "id": "c1b5e5d1", + "metadata": {}, + "outputs": [], + "source": [ + "it_companies = [\"Facebook\", \"Google\", \"Microsoft\", \"Apple\", \"IBM\", \"Oracle\", \"Amazon\"] #6\n" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "6ac87a4d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sorry, google doesn't exist in that list\n" + ] + } + ], + "source": [ + "lookup = input(\"Type a company name and I'll see if it exists in it_companies: \") #15\n", + "# if it_companies.index(lookup) != -1 :\n", + "# print(f\"Yes, {lookup} exists in it_companies.\\nIt is the item number {it_companies.index(lookup)+1} from right.\")\n", + "# else:\n", + "# print(f\"Sorry, {lookup} doesn't exist in that list\")\n", + "\n", + "#! This is probably a better method (because it can deal with the errors):\n", + "#? How to make an if to make it point from left or right depending on the closest path.\n", + "try:\n", + " print(f\"Yes, {lookup} exists in it_companies.\\nIt is the item number {it_companies.index(lookup)+1} from right.\")\n", + "except ValueError: \n", + " print(f\"Sorry, {lookup} doesn't exist in that list\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "b0195a1c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "NO\n" + ] + } + ], + "source": [ + "user_company = input(\"Type a company name and I'll see if it exists in it_companies: \").lower().strip() #15\n", + "\n", + "lower_companies = []\n", + "for company in it_companies:\n", + " new_company = company.lower().strip()\n", + " lower_companies.append(new_company)\n", + "\n", + "exist = user_company in lower_companies\n", + "\n", + "if exist:\n", + " print(\"Yes\")\n", + "else:\n", + " print(\"NO\")" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "b83138eb", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['IBM', 'Oracle', 'Amazon']\n", + "['IBM', 'Oracle']\n", + "1\n", + "2\n", + "3\n", + "4\n" + ] + } + ], + "source": [ + "print(it_companies[-3:]) #19\n", + "print(it_companies[-3:-1])\n", + "\n", + "for number in range(1, 5):\n", + " print(number)" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "id": "837f1634", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Facebook', 'Google', 'Microsoft', 'IBM', 'Oracle', 'Amazon']\n" + ] + } + ], + "source": [ + "middle_company_idx= round(len(it_companies)/2)\n", + "\n", + "del it_companies[middle_company_idx-1] #22\n", + "print(it_companies)" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "id": "967378b6", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Facebook', 'Google', 'Microsoft', 'IBM', 'Oracle']\n", + "Amazon\n" + ] + } + ], + "source": [ + "last = it_companies.pop() #23\n", + "print(it_companies)\n", + "print(last)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "553517b7", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[]\n" + ] + } + ], + "source": [ + "it_companies.clear()\n", + "print(it_companies)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "id": "de1a3d0e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['HTML', 'CSS', 'JS', 'React', 'Redux', 'Node', 'Express', 'MongoDB']\n" + ] + } + ], + "source": [ + "front_end = ['HTML', 'CSS', 'JS', 'React', 'Redux']\n", + "back_end = ['Node','Express', 'MongoDB']\n", + "\n", + "\n", + "full_stack = front_end + back_end\n", + "\n", + "print(full_stack)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a01b6cc1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['HTML', 'CSS', 'JS', 'React', 'Redux', 'Python', 'SQL', 'Node', 'Express', 'MongoDB']\n" + ] + } + ], + "source": [ + "full_stack.insert(full_stack.index(\"Redux\") + 1 , 'Python')\n", + "full_stack.insert(full_stack.index(\"Python\")+ 1, 'SQL')\n", + "print(full_stack)" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "id": "02567c13", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The min age is 19 and the max age is 26.\n", + "[19, 19, 20, 22, 24, 24, 24, 25, 25, 26, 19, 26]\n" + ] + } + ], + "source": [ + "ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24]\n", + "\n", + "ages.sort()\n", + "max_age = max(ages)\n", + "min_age = min(ages)\n", + "# print(f\"The min age is {ages[0]} and the max age is {ages[-1]}.\")\n", + "print(f\"The min age is {min_age} and the max age is {max_age}.\")\n", + "\n", + "ages.append(min_age)\n", + "ages.append(max_age)\n", + "print(ages)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "id": "a3b19aa0", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The median age is 25\n" + ] + } + ], + "source": [ + "ages.sort()\n", + "\n", + "# 1 2 3 4\n", + "# 1 2 3 4 5\n", + "median_idx = round(len(ages)/2)\n", + "\n", + "if len(ages) % 2 == 0: #even\n", + " median_age = (ages[median_idx] + ages[median_idx-1]) /2 \n", + " \n", + "else:\n", + " median_age = ages[median_idx]\n", + "\n", + "\n", + "\n", + "# median_age = (ages[5] + ages[6])/2\n", + "\n", + "print(f\"The median age is {round(median_age)}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "id": "7f67b456", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The average age is around 22.8\n", + "273\n" + ] + } + ], + "source": [ + "# average_age = (ages[0]+ages[1]+ages[2]+ages[3]+ages[4]+ages[5]+ages[6]+ages[7]+ages[8]+ages[9]+ages[10]+ages[11])/len(ages)\n", + "average_age = sum(ages) / len(ages)\n", + "\n", + "\n", + "\n", + "print(f\"The average age is around {round(average_age, 1)}\")\n", + "\n", + "\n", + "\n", + "my_sum = 0 \n", + "for age in ages:\n", + " my_sum += age\n", + "\n", + "print(my_sum)" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "id": "69ece82a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The range of the ages is 7\n" + ] + } + ], + "source": [ + "ages_range = max(ages) - min(ages)\n", + "print(f\"The range of the ages is {round(ages_range)}\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "id": "bdf39023", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.25\n", + "3.75\n" + ] + } + ], + "source": [ + "print(abs(ages[-1] - average_age))\n", + "print(abs(ages[0] - average_age))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "811b192a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "22.75\n", + "24.0\n", + "2.800162332956625\n", + "273\n" + ] + } + ], + "source": [ + "#!\n", + "#! طبيز\n", + "\n", + "import pandas as pd\n", + "\n", + "ages_serise = pd.Series(ages)\n", + "mean = ages_serise.mean()\n", + "median_age = ages_serise.median()\n", + "std = ages_serise.std()\n", + "summission = ages_serise.sum()\n", + "print(mean)\n", + "print(median_age)\n", + "print(std)\n", + "print(summission)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "id": "5947fe23", + "metadata": {}, + "outputs": [], + "source": [ + "countries = [\n", + " 'Afghanistan',\n", + " 'Albania',\n", + " 'Algeria',\n", + " 'Andorra',\n", + " 'Angola',\n", + " 'Antigua and Barbuda',\n", + " 'Argentina',\n", + " 'Armenia',\n", + " 'Australia',\n", + " 'Austria',\n", + " 'Azerbaijan',\n", + " 'Bahamas',\n", + " 'Bahrain',\n", + " 'Bangladesh',\n", + " 'Barbados',\n", + " 'Belarus',\n", + " 'Belgium',\n", + " 'Belize',\n", + " 'Benin',\n", + " 'Bhutan',\n", + " 'Bolivia',\n", + " 'Bosnia and Herzegovina',\n", + " 'Botswana',\n", + " 'Brazil',\n", + " 'Brunei',\n", + " 'Bulgaria',\n", + " 'Burkina Faso',\n", + " 'Burundi',\n", + " 'Cambodia',\n", + " 'Cameroon',\n", + " 'Canada',\n", + " 'Cape Verde',\n", + " 'Central African Republic',\n", + " 'Chad',\n", + " 'Chile',\n", + " 'China',\n", + " 'Colombi',\n", + " 'Comoros',\n", + " 'Congo (Brazzaville)',\n", + " 'Congo',\n", + " 'Costa Rica',\n", + " \"Cote d'Ivoire\",\n", + " 'Croatia',\n", + " 'Cuba',\n", + " 'Cyprus',\n", + " 'Czech Republic',\n", + " 'Denmark',\n", + " 'Djibouti',\n", + " 'Dominica',\n", + " 'Dominican Republic',\n", + " 'East Timor (Timor Timur)',\n", + " 'Ecuador',\n", + " 'Egypt',\n", + " 'El Salvador',\n", + " 'Equatorial Guinea',\n", + " 'Eritrea',\n", + " 'Estonia',\n", + " 'Ethiopia',\n", + " 'Fiji',\n", + " 'Finland',\n", + " 'France',\n", + " 'Gabon',\n", + " 'Gambia, The',\n", + " 'Georgia',\n", + " 'Germany',\n", + " 'Ghana',\n", + " 'Greece',\n", + " 'Grenada',\n", + " 'Guatemala',\n", + " 'Guinea',\n", + " 'Guinea-Bissau',\n", + " 'Guyana',\n", + " 'Haiti',\n", + " 'Honduras',\n", + " 'Hungary',\n", + " 'Iceland',\n", + " 'India',\n", + " 'Indonesia',\n", + " 'Iran',\n", + " 'Iraq',\n", + " 'Ireland',\n", + " 'Israel',\n", + " 'Italy',\n", + " 'Jamaica',\n", + " 'Japan',\n", + " 'Jordan',\n", + " 'Kazakhstan',\n", + " 'Kenya',\n", + " 'Kiribati',\n", + " 'Korea, North',\n", + " 'Korea, South',\n", + " 'Kuwait',\n", + " 'Kyrgyzstan',\n", + " 'Laos',\n", + " 'Latvia',\n", + " 'Lebanon',\n", + " 'Lesotho',\n", + " 'Liberia',\n", + " 'Libya',\n", + " 'Liechtenstein',\n", + " 'Lithuania',\n", + " 'Luxembourg',\n", + " 'Macedonia',\n", + " 'Madagascar',\n", + " 'Malawi',\n", + " 'Malaysia',\n", + " 'Maldives',\n", + " 'Mali',\n", + " 'Malta',\n", + " 'Marshall Islands',\n", + " 'Mauritania',\n", + " 'Mauritius',\n", + " 'Mexico',\n", + " 'Micronesia',\n", + " 'Moldova',\n", + " 'Monaco',\n", + " 'Mongolia',\n", + " 'Morocco',\n", + " 'Mozambique',\n", + " 'Myanmar',\n", + " 'Namibia',\n", + " 'Nauru',\n", + " 'Nepal',\n", + " 'Netherlands',\n", + " 'New Zealand',\n", + " 'Nicaragua',\n", + " 'Niger',\n", + " 'Nigeria',\n", + " 'Norway',\n", + " 'Oman',\n", + " 'Pakistan',\n", + " 'Palau',\n", + " 'Panama',\n", + " 'Papua New Guinea',\n", + " 'Paraguay',\n", + " 'Peru',\n", + " 'Philippines',\n", + " 'Poland',\n", + " 'Portugal',\n", + " 'Qatar',\n", + " 'Romania',\n", + " 'Russia',\n", + " 'Rwanda',\n", + " 'Saint Kitts and Nevis',\n", + " 'Saint Lucia',\n", + " 'Saint Vincent',\n", + " 'Samoa',\n", + " 'San Marino',\n", + " 'Sao Tome and Principe',\n", + " 'Saudi Arabia',\n", + " 'Senegal',\n", + " 'Serbia and Montenegro',\n", + " 'Seychelles',\n", + " 'Sierra Leone',\n", + " 'Singapore',\n", + " 'Slovakia',\n", + " 'Slovenia',\n", + " 'Solomon Islands',\n", + " 'Somalia',\n", + " 'South Africa',\n", + " 'Spain',\n", + " 'Sri Lanka',\n", + " 'Sudan',\n", + " 'Suriname',\n", + " 'Swaziland',\n", + " 'Sweden',\n", + " 'Switzerland',\n", + " 'Syria',\n", + " 'Taiwan',\n", + " 'Tajikistan',\n", + " 'Tanzania',\n", + " 'Thailand',\n", + " 'Togo',\n", + " 'Tonga',\n", + " 'Trinidad and Tobago',\n", + " 'Tunisia',\n", + " 'Turkey',\n", + " 'Turkmenistan',\n", + " 'Tuvalu',\n", + " 'Uganda',\n", + " 'Ukraine',\n", + " 'United Arab Emirates',\n", + " 'United Kingdom',\n", + " 'United States',\n", + " 'Uruguay',\n", + " 'Uzbekistan',\n", + " 'Vanuatu',\n", + " 'Vatican City',\n", + " 'Venezuela',\n", + " 'Vietnam',\n", + " 'Yemen',\n", + " 'Zambia',\n", + " 'Zimbabwe',\n", + "]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "id": "17fb4fe8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "96\n", + "The middle country is Lebanon\n", + "['Afghanistan', 'Albania', 'Algeria', 'Andorra', 'Angola', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Central African Republic', 'Chad', 'Chile', 'China', 'Colombi', 'Comoros', 'Congo (Brazzaville)', 'Congo', 'Costa Rica', \"Cote d'Ivoire\", 'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'East Timor (Timor Timur)', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Fiji', 'Finland', 'France', 'Gabon', 'Gambia, The', 'Georgia', 'Germany', 'Ghana', 'Greece', 'Grenada', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kiribati', 'Korea, North', 'Korea, South', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho']\n", + "USA\n", + "['Finland', 'Sweden', 'Norway', 'Denmark']\n" + ] + } + ], + "source": [ + "# print(len(countries))\n", + "# 1 2 3 4 5\n", + "middle_country_idx = (round(len(countries)/2))\n", + "print(middle_country_idx)\n", + "print(f\"The middle country is {countries[middle_country_idx-1]}\")\n", + "\n", + "if len(countries) % 2 == 0:\n", + " first_countries = countries[0:(middle_country_idx)]\n", + " last_countries = countries[middle_country_idx:]\n", + "else:\n", + " first_countries = countries[0:(middle_country_idx+1)]\n", + " last_countries = countries[middle_country_idx+1:]\n", + "print(first_countries)\n", + "\n", + "Sean, Rousia, Amrika, *Scandic = ['China', 'Russia', 'USA', 'Finland', 'Sweden', 'Norway', 'Denmark']\n", + "print(Amrika)\n", + "print(Scandic)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Day 5/Day_05_Exercises.py b/Day 5/Day_05_Exercises.py new file mode 100644 index 000000000..d2cf530ec --- /dev/null +++ b/Day 5/Day_05_Exercises.py @@ -0,0 +1,312 @@ + +# DAY_05_Exercises + +# LEVEL 1 +empty_list = [] #1 +six_items = ["item1", "item2", "item3", "item4", "item5", "item6"] #2 +print(f"The length of six_items is {len(six_items)}") #3 +print(six_items[0], six_items[1], six_items[-1]) #4 +mixed_data_types = list(["Ahmad", 21, 192.5,"KHHV","Islamic University"]) #5 +it_companies = ["Facebook", "Google", "Microsoft", "Apple", "IBM", "Oracle", "Amazon"] #6 +print(it_companies) #7 +print(f"The length of it_companies is {len(it_companies)}") #8 + +#! Attempted to make a print that'll always print the middle company REGARDLESS of the number of companies :P +middle_company_idx= round(len(it_companies)/2) +print(it_companies[0], it_companies[middle_company_idx -1], it_companies[-1]) #9 +it_companies[0] = "Telegram" +print(it_companies) #10 +it_companies.append("X") #11 +print(it_companies) +middle_company_idx = round(len(it_companies)/2) +it_companies.insert(middle_company_idx, "LinkedIn") #12 +print(it_companies) +it_companies[3] = it_companies[3].upper() #13 +print(it_companies) + +joined_companies1 = '#; '.join(it_companies) #14 +print(joined_companies1) + +lookup = input("Type a company name and I'll see if it exists in it_companies: ") #15 +# if it_companies.index(lookup) != -1 : +# print(f"Yes, {lookup} exists in it_companies.\nIt is the item number {it_companies.index(lookup)+1} from right.") +# else: +# print(f"Sorry, {lookup} doesn't exist in that list") + +#! This is probably a better method (because it can deal with the errors): +#? How to make an if to make it point from left or right depending on the closest path. +try: + print(f"Yes, {lookup} exists in it_companies.\nIt is the item number {it_companies.index(lookup)+1} from right.") +except ValueError: + print(f"Sorry, {lookup} doesn't exist in that list") + +sorted_it_companies = sorted(it_companies) #16 (better?) +print(f"This is the list in alphabetical order:\n {sorted_it_companies}") +it_companies.sort() #16 +print(it_companies) + +it_companies.reverse() #17 +print(it_companies) + +print(it_companies[0:3]) #18 + +print(it_companies[-3:]) #19 +#! Why is print(it_companies[-3:-1]) wrong? + +middle_company_idx = round(len(it_companies)/2) +print(it_companies[middle_company_idx-2], it_companies[middle_company_idx-1], it_companies[middle_company_idx]) #20 (REGARDLESS OF NUMBER OF ITEMS) +print(it_companies[2:5]) #20 (Won't work if the list gets modified) + +it_companies.pop(0) #21 +print(it_companies) + +del it_companies[middle_company_idx-1] #22 +print(it_companies) + +it_companies.pop() #23 +print(it_companies) + +del it_companies[0:] #24 #? Other methods? +print(it_companies) + +del it_companies #25 + +front_end = ['HTML', 'CSS', 'JS', 'React', 'Redux'] +back_end = ['Node','Express', 'MongoDB'] + +front_end.extend(back_end) #26 + +full_stack = front_end.copy() #27 +full_stack.insert(4, 'Python') +full_stack.insert(5, 'SQL') +print(full_stack) + +# LEVEL 2 + +ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24] + +ages.sort() +print(f"The min age is {ages[0]} and the max age is {ages[-1]}.") +ages.append(ages[0]) +ages.append(ages[-2]) +print(ages) + +median_age = (ages[5] + ages[6])/2 +print(f"The median age is {round(median_age)}") + +average_age = (ages[0]+ages[1]+ages[2]+ages[3]+ages[4]+ages[5]+ages[6]+ages[7]+ages[8]+ages[9]+ages[10]+ages[11])/len(ages) +print(f"The average age is around {round(average_age, 1)}") + +ages.sort() +print(f"The range of the ages is {round(ages[-1] - ages[0])}") + +abs(ages[-1] - average_age) +abs(ages[0] - average_age) + +countries = [ + 'Afghanistan', + 'Albania', + 'Algeria', + 'Andorra', + 'Angola', + 'Antigua and Barbuda', + 'Argentina', + 'Armenia', + 'Australia', + 'Austria', + 'Azerbaijan', + 'Bahamas', + 'Bahrain', + 'Bangladesh', + 'Barbados', + 'Belarus', + 'Belgium', + 'Belize', + 'Benin', + 'Bhutan', + 'Bolivia', + 'Bosnia and Herzegovina', + 'Botswana', + 'Brazil', + 'Brunei', + 'Bulgaria', + 'Burkina Faso', + 'Burundi', + 'Cambodia', + 'Cameroon', + 'Canada', + 'Cape Verde', + 'Central African Republic', + 'Chad', + 'Chile', + 'China', + 'Colombi', + 'Comoros', + 'Congo (Brazzaville)', + 'Congo', + 'Costa Rica', + "Cote d'Ivoire", + 'Croatia', + 'Cuba', + 'Cyprus', + 'Czech Republic', + 'Denmark', + 'Djibouti', + 'Dominica', + 'Dominican Republic', + 'East Timor (Timor Timur)', + 'Ecuador', + 'Egypt', + 'El Salvador', + 'Equatorial Guinea', + 'Eritrea', + 'Estonia', + 'Ethiopia', + 'Fiji', + 'Finland', + 'France', + 'Gabon', + 'Gambia, The', + 'Georgia', + 'Germany', + 'Ghana', + 'Greece', + 'Grenada', + 'Guatemala', + 'Guinea', + 'Guinea-Bissau', + 'Guyana', + 'Haiti', + 'Honduras', + 'Hungary', + 'Iceland', + 'India', + 'Indonesia', + 'Iran', + 'Iraq', + 'Ireland', + 'Israel', + 'Italy', + 'Jamaica', + 'Japan', + 'Jordan', + 'Kazakhstan', + 'Kenya', + 'Kiribati', + 'Korea, North', + 'Korea, South', + 'Kuwait', + 'Kyrgyzstan', + 'Laos', + 'Latvia', + 'Lebanon', + 'Lesotho', + 'Liberia', + 'Libya', + 'Liechtenstein', + 'Lithuania', + 'Luxembourg', + 'Macedonia', + 'Madagascar', + 'Malawi', + 'Malaysia', + 'Maldives', + 'Mali', + 'Malta', + 'Marshall Islands', + 'Mauritania', + 'Mauritius', + 'Mexico', + 'Micronesia', + 'Moldova', + 'Monaco', + 'Mongolia', + 'Morocco', + 'Mozambique', + 'Myanmar', + 'Namibia', + 'Nauru', + 'Nepal', + 'Netherlands', + 'New Zealand', + 'Nicaragua', + 'Niger', + 'Nigeria', + 'Norway', + 'Oman', + 'Pakistan', + 'Palau', + 'Panama', + 'Papua New Guinea', + 'Paraguay', + 'Peru', + 'Philippines', + 'Poland', + 'Portugal', + 'Qatar', + 'Romania', + 'Russia', + 'Rwanda', + 'Saint Kitts and Nevis', + 'Saint Lucia', + 'Saint Vincent', + 'Samoa', + 'San Marino', + 'Sao Tome and Principe', + 'Saudi Arabia', + 'Senegal', + 'Serbia and Montenegro', + 'Seychelles', + 'Sierra Leone', + 'Singapore', + 'Slovakia', + 'Slovenia', + 'Solomon Islands', + 'Somalia', + 'South Africa', + 'Spain', + 'Sri Lanka', + 'Sudan', + 'Suriname', + 'Swaziland', + 'Sweden', + 'Switzerland', + 'Syria', + 'Taiwan', + 'Tajikistan', + 'Tanzania', + 'Thailand', + 'Togo', + 'Tonga', + 'Trinidad and Tobago', + 'Tunisia', + 'Turkey', + 'Turkmenistan', + 'Tuvalu', + 'Uganda', + 'Ukraine', + 'United Arab Emirates', + 'United Kingdom', + 'United States', + 'Uruguay', + 'Uzbekistan', + 'Vanuatu', + 'Vatican City', + 'Venezuela', + 'Vietnam', + 'Yemen', + 'Zambia', + 'Zimbabwe', +] +# print(len(countries)) +middle_country = (round(len(countries)/2)) +print(middle_country) +print(f"The middle country is {countries[middle_country-1]}") + +first_countries = countries[0:(middle_country)] +last_countries = countries[middle_country+1:-1] +print(first_countries) + +Sean, Rousia, Amrika, *Scandic = ['China', 'Russia', 'USA', 'Finland', 'Sweden', 'Norway', 'Denmark'] +print(Amrika) +print(Scandic) \ No newline at end of file diff --git a/Day 5/image.png b/Day 5/image.png new file mode 100644 index 000000000..5ed4dd18d Binary files /dev/null and b/Day 5/image.png differ diff --git a/Day 6/Day_06_Exercises.ipynb b/Day 6/Day_06_Exercises.ipynb new file mode 100644 index 000000000..2a8407626 --- /dev/null +++ b/Day 6/Day_06_Exercises.ipynb @@ -0,0 +1,89 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "d82e15e2", + "metadata": {}, + "outputs": [], + "source": [ + "meyveler = ('elma','hurma','muz')\n", + "sebzeler = ('domates','patates','kabak')\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "0156c236", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('muz',)\n", + "\n" + ] + } + ], + "source": [ + "yemek_tp = meyveler + sebzeler #2\n", + "yemek_lt = list(yemek_tp) #3\n", + "\n", + "yarim_yemek = yemek_tp[2:3] #4\n", + "\n", + "print(yarim_yemek)\n", + "print(type(yarim_yemek))" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "5bc5374c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['domates', 'patates', 'kabak']\n" + ] + } + ], + "source": [ + "meyveler = ('elma','hurma','muz','purtukan')\n", + "sebzeler = ('domates','patates','kabak')\n", + "yemek_tp = meyveler + sebzeler #2\n", + "yemek_lt = list(yemek_tp) #3\n", + "\n", + "yarim_yemek = yemek_tp[2:3] #4\n", + "\n", + "s1 = yemek_lt[0:3]\n", + "s2 = yemek_lt[-3:] #5\n", + "\n", + "print(s2)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Day 6/Day_06_Exercises.py b/Day 6/Day_06_Exercises.py new file mode 100644 index 000000000..6e0ed8d47 --- /dev/null +++ b/Day 6/Day_06_Exercises.py @@ -0,0 +1,32 @@ +# LEVEL 1 + +emp = tuple() #1 +cpu_archeticture = ('comet_lake','tiger_lake','raptor_lake') #2 +gpu_archeticture = ('Maxwell','Blackwell','Turing') #2 +computer = cpu_archeticture + gpu_archeticture #3 +print(len(computer)) #4 + +extras = ('RAM','Stoarge') +full_computer = computer + extras #5 +print(full_computer) + +# LEVEL 2 +*stuff, volatile, non_volatile = full_computer #1 +print(stuff) +print(volatile) + +meyveler = ('elma','hurma','muz') +sebzeler = ('domates','patates','kabak') +yemek_tp = meyveler + sebzeler #2 +yemek_lt = list(yemek_tp) #3 + +yarim_yemek = yemek_tp[2:3] #4 + +s1 = yemek_lt[0:3] +s2 = yemek_lt[-3:] #5 + +del yemek_tp #6 + +nordic_countries = ('Denmark', 'Finland','Iceland', 'Norway', 'Sweden') +print(f"Estonia is a nordic country is a {('Estonia' in nordic_countries).lower()} statement.") +print(f"Iceland is a nordic country is a {'Iceland' in nordic_countries} statement.") \ No newline at end of file diff --git a/Day 7/Day_07_Exercises.ipynb b/Day 7/Day_07_Exercises.ipynb new file mode 100644 index 000000000..17d120b2b --- /dev/null +++ b/Day 7/Day_07_Exercises.ipynb @@ -0,0 +1,140 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "7206bd35", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n", + "{'Oracle', 'Google', 'Facebook', 'Microsoft', 'Amazon', 'IBM', 'Apple', 'Twitter'}\n", + "{'Oracle', 'Facebook', 'Lenovo', 'Samsung', 'Twitter', 'Dell', 'IBM', 'Google', 'Microsoft', 'Amazon', 'Apple'}\n" + ] + } + ], + "source": [ + "it_companies = {'Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle', 'Amazon'}\n", + "\n", + "print(len(it_companies)) #1\n", + "it_companies.add('Twitter') #2\n", + "print(it_companies)\n", + "\n", + "it_companies.update(['Lenovo','Samsung','Dell'])\n", + "print(it_companies) #3\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "9f959bc8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "We have randomly selected Oracle and removed it from the set.\n" + ] + } + ], + "source": [ + "random_pop = it_companies.pop() #4\n", + "print(f\"We have randomly selected {random_pop} and removed it from the set.\")" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "6a54d12e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "None\n" + ] + } + ], + "source": [ + "diff_test = input('Enter a random value to test: ')\n", + "random_pop2 = it_companies.discard(diff_test)\n", + "\n", + "print(random_pop2)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "f45f28cb", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n" + ] + } + ], + "source": [ + "set_ = {1,2,3,4}\n", + "\n", + "for num in set_:\n", + " print(num)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "588b7c7e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['I', 'am', 'a', 'teacher', 'and', 'I', 'love', 'to', 'inspire', 'and', 'teach', 'people.']\n", + "The unique words used in the sentence are:\n", + " {'teacher', 'inspire', 'people.', 'a', 'teach', 'and', 'love', 'to', 'I', 'am'}\n" + ] + } + ], + "source": [ + "sentence = \"I am a teacher and I love to inspire and teach people.\"\n", + "sentence_list = sentence.split()\n", + "print(sentence_list)\n", + "sentence_set = set(sentence_list)\n", + "print(\"The unique words used in the sentence are:\\n\", sentence_set)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Day 7/Day_07_Exercises.py b/Day 7/Day_07_Exercises.py new file mode 100644 index 000000000..4a8a57afe --- /dev/null +++ b/Day 7/Day_07_Exercises.py @@ -0,0 +1,71 @@ +# LEVEL 1 +# sets +it_companies = {'Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle', 'Amazon'} + +print(len(it_companies)) #1 +it_companies.add('Twitter') #2 +print(it_companies) + +it_companies.update(['Lenovo','Samsung','Dell']) +print(it_companies) #3 + +random_pop = it_companies.pop() #4 +print(f"We have randomly selected {random_pop} and removed it from the set.") + +# diff_test = input('Enter a random value to test: ') +#! random_pop2 = it_companies.remove(diff_test) + +''' +The difference between .discard() and .remove() is that .remove() raises a key error if item to be +deleted was not found while .discard() doesn't. #* #5 +''' + +# LEVEL 2 +A = {19, 22, 24, 20, 25, 26} +B = {19, 22, 20, 25, 26, 24, 28, 27} + +# AB = A + B +# print(AB) +# I forgot how sets work lol + +A_union_B = A.union(B) #1 +print(A_union_B) + +A_intersection_B = A.intersection(B) #2 +print(A_intersection_B) + +print(f'"A is a subset of B."\nThe above sentence is a {str(A.issubset(B)).lower()} statement.') #3 + +print(f'"A and B are disjoint sets."\nThe above sentence is a {str(A.isdisjoint(B)).lower()} statement.') #4 + +AB = A.union(B) #5 +print(AB) +BA = B.union(A) +print(BA) + +print(f"The symmetric difference between A and B is {A.symmetric_difference(B)}") #6 +print(f"The difference between B and A is {B.difference(A)}") + +del A #7 +del B + +# LEVEL 3 +age = [22, 19, 24, 25, 26, 24, 25, 24] + +ageset = set(age) +print(age, ageset) +print(f"The difference between length of age list and length of age set is {abs(len(age) - len(ageset))}") #2 (List is bigger) + +# string VS list VS tuple VS set #2 + +#* (Data Type) (Definition) (Indexed?) (Modifiable?) +# string bunch of characters YES YES +# list bunch of items YES YES +# tuple bunch of items YES NO +# set bunch of items NO NO + +sentence = "I am a teacher and I love to inspire and teach people." +sentence_list = sentence.split() +print(sentence_list) +sentence_set = set(sentence_list) +print("The unique words used in the sentence are:\n", sentence_set) \ No newline at end of file diff --git a/Day 8/Day_08_Exercise.ipynb b/Day 8/Day_08_Exercise.ipynb new file mode 100644 index 000000000..af71ed223 --- /dev/null +++ b/Day 8/Day_08_Exercise.ipynb @@ -0,0 +1,105 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "id": "ca13227f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9\n", + "\n", + "['professional sleeping', 'graphic design', 'animation', 'primitive coding', 'Turkish', 'CAD Modeling']\n" + ] + } + ], + "source": [ + "student = {\n", + " 'name':'Ahmed',\n", + " 'surname':'Sanosi',\n", + " 'gender':'male',\n", + " 'age':'??',\n", + " 'martial status':'single variable calculus',\n", + " 'skills':['professional sleeping','graphic design', 'animation','primitive coding'],\n", + " 'country':'Sudan',\n", + " 'city':'Khartoum',\n", + " 'address':'Square 1'\n", + "} #3\n", + "\n", + "print(len(student)) #4\n", + "\n", + "skills_type = type(student['skills']) #5\n", + "print(skills_type)\n", + "\n", + "# student['skills'] = student['skills'].append('Turkish') #! Wrong\n", + "student['skills'].extend([\"Turkish\", \"CAD Modeling\"])\n", + "\n", + "print(student[\"skills\"])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a4dab0b5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dict_items([('name', 'Ahmed'), ('surname', 'Sanosi'), ('gender', 'male'), ('age', '??'), ('martial status', 'single variable calculus'), ('skills', ['professional sleeping', 'graphic design', 'animation', 'primitive coding', 'Turkish', 'CAD Modeling']), ('country', 'Sudan'), ('city', 'Khartoum'), ('address', 'Square 1')])\n" + ] + } + ], + "source": [ + "stuple = student.items() #9\n", + "print(stuple)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "b9682535", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'name': 'Ahmed', 'surname': 'Sanosi', 'gender': 'male', 'age': '??', 'skills': ['professional sleeping', 'graphic design', 'animation', 'primitive coding', 'Turkish', 'CAD Modeling'], 'country': 'Sudan', 'city': 'Khartoum', 'address': 'Square 1'}\n", + "single variable calculus\n" + ] + } + ], + "source": [ + "ms = student.pop('martial status')\n", + "print(student)\n", + "print(ms)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Day 8/Day_08_Exercises.py b/Day 8/Day_08_Exercises.py new file mode 100644 index 000000000..91434c977 --- /dev/null +++ b/Day 8/Day_08_Exercises.py @@ -0,0 +1,44 @@ +dog = {} #1 +dog['name'] = 'Baxter' +dog['color'] = 'White' +dog['breed'] = 'Chiuaua' +dog['legs'] = 4 +dog['age'] = 3 +print(dog) #2 + +student = { + 'name':'Ahmed', + 'surname':'Sanosi', + 'gender':'male', + 'age':'??', + 'martial status':'single variable calculus', + 'skills':['professional sleeping','graphic design', 'animation','primitive coding'], + 'country':'Sudan', + 'city':'Khartoum', + 'address':'Square 1' +} #3 + +print(len(student)) #4 + +skills_type = type(student['skills']) #5 +print(skills_type) + +# student['skills'] = student['skills'].append('Turkish') #! Wrong +student['skills'].append('Turkish') #6 +student['skills'].append('CAD Modeling') +print(student['skills']) + +skeys = student.keys() #7 +print(skeys) + +svalues = student.values() #8 +print(svalues) + +stuple = student.items() #9 +print(stuple) + +student.pop('martial status') +print(student) + +del student +print(student) \ No newline at end of file