diff --git a/01_Day_Introduction/data_types_Alexa.py b/01_Day_Introduction/data_types_Alexa.py new file mode 100644 index 000000000..77ec14c82 --- /dev/null +++ b/01_Day_Introduction/data_types_Alexa.py @@ -0,0 +1,73 @@ +a = type(10) +print(a) + +b = type(9.8) +print(b) + +c = type(3.14) +print(c) + +d = type(4 - 4j) +print(d) + +e = type(['Asabeneh', 'Python', 'Finland']) +print(e) + +f = type('Your name') +print(f) + +g = type('Your family name') +print(g) + +h = type('Your country') +print(h) + +#Integer +i = 30 +print(i) + +#Float +j = 5.5 +print(j) + +#Complex +k = (5 - 5j) +print(k) + +#String +l = "What a wounderful world" +print(l) + +#Boolean +m = 5 < 4 +print(m) + +#List +n = ['Alexa', 'Giraffe', 300] +print(n) + +#Tuple +o = ('banana', 'kiwi', 'strawberry') +print(o) + +#Set +p = {'jason', 23, 5 == 5} +print(p) + +#Dictionary data type +q_dict = {"k": (5 - 5j), "l": "What a wonderful world"} +print(q_dict) + +#Find an Euclidian distance between (2, 3) and (10, 8) + +import math + +# Define the two points (p and q) as lists of coordinates +p = [2, 3] # Represents the point (2, 3) +q = [10, 8] # Represents the point (10, 8) + +# Calculate the Euclidean distance +distance = math.dist(p, q) + +# Print the result +print(distance) diff --git a/02_Day_Variables_builtin_functions/day 2 b/02_Day_Variables_builtin_functions/day 2 new file mode 100644 index 000000000..d1581552d --- /dev/null +++ b/02_Day_Variables_builtin_functions/day 2 @@ -0,0 +1 @@ +#day 2 \ No newline at end of file diff --git a/02_Day_Variables_builtin_functions/variables_Alexa.py b/02_Day_Variables_builtin_functions/variables_Alexa.py new file mode 100644 index 000000000..b75e29b34 --- /dev/null +++ b/02_Day_Variables_builtin_functions/variables_Alexa.py @@ -0,0 +1,90 @@ +#Day 2: 30 days of python programming + +import math +import keyword + + +first_name = 'Alexa' +last_name = 'Garcia' +full_name = first_name + " " + last_name + +country = 'United States' +city = 'Salt Lake City' +age = 37 +year = 2025 +is_married = False +is_true = True +is_light_on = True +demographics = { + 'full_name': full_name, + 'country': country, + 'city': city +} + + +print(first_name) +print(len(first_name)) + +print(last_name) +print(len(last_name)) + +print(full_name) +print(len(full_name)) + +print(country) +print(len(country)) + +print(city) +print(len(city)) + +print(age) #int has no len + +print(year) #int has no len + +print(is_married) #bool has no len + +print(is_true) #bool has no len + +print(is_light_on) #bool has no len + +print(demographics) +print(len(demographics)) + +#assigning int values to find sum +num_one = 5 +num_two = 4 +total_sum = num_one + num_two +diff = num_one - num_two +product = num_one * num_two +result = num_one / num_two +remainder = num_one % num_two +exp = num_one ** num_two +floor_division = num_one // num_two + +#Calculate the area of a circle and assign the value to a variable name of area_of_circle +radius = 30 +area_of_circle = math.pi * (radius ** 2) +#Calculate the circumference of a circle and assign the value to a variable name of circum_of_circle +circum_of_circle = 2 * math.pi * radius + +##Take radius as user input and calculate the area +# Get radius as user input +radius = float(input("Enter the radius of the circle:" + " ")) +# Calculate the area +area = math.pi * (radius ** 2) +# Display the result +print(f"The area of the circle with radius {radius} is: {area}") + +#Use the built-in input function to get first name, last name, country and age from a user and store the value to their corresponding variable names +user_first_name = input("First Name:" + " ") +user_last_name = input("Last Name:" + " ") +user_country = input("Country:" + " ") +user_age = int(input("Age:" + " ")) + +#Run help('keywords') in Python shell or in your file to check for the Python reserved words or keywords + +print(keyword.kwlist) +#['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', +#'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', +#'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', +#'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'] diff --git a/02_Day_Variables_builtin_functions/variables_Alexa.py.ipynb b/02_Day_Variables_builtin_functions/variables_Alexa.py.ipynb new file mode 100644 index 000000000..2c3953b5e --- /dev/null +++ b/02_Day_Variables_builtin_functions/variables_Alexa.py.ipynb @@ -0,0 +1,165 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyPYdNylgu9hKpcCnZhtWO4x", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "GWRo3hMeIP8A", + "outputId": "24e7fdcb-fd1a-4a57-fc44-708fe5a3044e" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Alexa\n", + "5\n", + "Garcia\n", + "6\n", + "Alexa Garcia\n", + "12\n", + "United States\n", + "13\n", + "Salt Lake City\n", + "14\n", + "37\n", + "2025\n", + "False\n", + "True\n", + "True\n", + "{'full_name': 'Alexa Garcia', 'country': 'United States', 'city': 'Salt Lake City'}\n", + "3\n", + "Enter the radius of the circle: 33\n", + "The area of the circle with radius 33.0 is: 3421.194399759285\n", + "First Name: Alexa\n", + "Last Name: Garcia\n", + "Country: United States\n", + "Age: 33\n", + "['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']\n" + ] + } + ], + "source": [ + "#Day 2: 30 days of python programming\n", + "\n", + "import math\n", + "import keyword\n", + "\n", + "\n", + "first_name = 'Alexa'\n", + "last_name = 'Garcia'\n", + "full_name = first_name + \" \" + last_name\n", + "\n", + "country = 'United States'\n", + "city = 'Salt Lake City'\n", + "age = 37\n", + "year = 2025\n", + "is_married = False\n", + "is_true = True\n", + "is_light_on = True\n", + "demographics = {\n", + " 'full_name': full_name,\n", + " 'country': country,\n", + " 'city': city\n", + "}\n", + "\n", + "\n", + "print(first_name)\n", + "print(len(first_name))\n", + "\n", + "print(last_name)\n", + "print(len(last_name))\n", + "\n", + "print(full_name)\n", + "print(len(full_name))\n", + "\n", + "print(country)\n", + "print(len(country))\n", + "\n", + "print(city)\n", + "print(len(city))\n", + "\n", + "print(age) #int has no len\n", + "\n", + "print(year) #int has no len\n", + "\n", + "print(is_married) #bool has no len\n", + "\n", + "print(is_true) #bool has no len\n", + "\n", + "print(is_light_on) #bool has no len\n", + "\n", + "print(demographics)\n", + "print(len(demographics))\n", + "\n", + "#assigning int values to find sum\n", + "num_one = 5\n", + "num_two = 4\n", + "total_sum = num_one + num_two\n", + "diff = num_one - num_two\n", + "product = num_one * num_two\n", + "result = num_one / num_two\n", + "remainder = num_one % num_two\n", + "exp = num_one ** num_two\n", + "floor_division = num_one // num_two\n", + "\n", + "#Calculate the area of a circle and assign the value to a variable name of area_of_circle\n", + "radius = 30\n", + "area_of_circle = math.pi * (radius ** 2)\n", + "#Calculate the circumference of a circle and assign the value to a variable name of circum_of_circle\n", + "circum_of_circle = 2 * math.pi * radius\n", + "\n", + "##Take radius as user input and calculate the area\n", + "# Get radius as user input\n", + "radius = float(input(\"Enter the radius of the circle:\" + \" \"))\n", + "# Calculate the area\n", + "area = math.pi * (radius ** 2)\n", + "# Display the result\n", + "print(f\"The area of the circle with radius {radius} is: {area}\")\n", + "\n", + "#Use the built-in input function to get first name, last name, country and age from a user and store the value to their corresponding variable names\n", + "user_first_name = input(\"First Name:\" + \" \")\n", + "user_last_name = input(\"Last Name:\" + \" \")\n", + "user_country = input(\"Country:\" + \" \")\n", + "user_age = int(input(\"Age:\" + \" \"))\n", + "\n", + "#Run help('keywords') in Python shell or in your file to check for the Python reserved words or keywords\n", + "\n", + "print(keyword.kwlist)\n", + "#['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break',\n", + "#'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for',\n", + "#'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or',\n", + "#'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']" + ] + } + ] +} \ No newline at end of file diff --git a/03_Day_Operators/day_03_operators_Alexa.py b/03_Day_Operators/day_03_operators_Alexa.py new file mode 100644 index 000000000..7107ea7d5 --- /dev/null +++ b/03_Day_Operators/day_03_operators_Alexa.py @@ -0,0 +1,23 @@ +#Exercises - Day 3 + +#Declare your age as integer variable +age = 35 +print(age) + +#Declare your height as a float variable +height_in_inches = 63.0 +print(height_in_inches + +#Declare a variable that store a complex number +complex = 3 + 4j +print(complex) + +#Write a script that prompts the user to enter base and height of the triangle + #and calculate an area of this triangle (area = 0.5 x b x h). + +user_input_base = input("enter base of triangle: " + ") +user_input_height = input("enter height of triangle: " + ") +# Calculating area of a circle +area = 0.5 +area_of_triangle = 3.14 * area ** 2 +print('Area of a triangle:', area_of_triangle) diff --git a/04_Day_Strings/strings_Alexa.py b/04_Day_Strings/strings_Alexa.py new file mode 100644 index 000000000..ec8fdc7e2 --- /dev/null +++ b/04_Day_Strings/strings_Alexa.py @@ -0,0 +1,104 @@ +#Concatenate the string 'Thirty', 'Days', 'Of', 'Python' to a single string, 'Thirty Days Of Python'. +words = ['Thirty', 'Days', 'Of', 'Python'] +result = " ".join(words) +print(result) + + +#Concatenate the string 'Coding', 'For' , 'All' to a single string, 'Coding For All'. +words = ['Coding', 'For' , 'All'] +result = " ".join(words) +print(result) + + +Declare a variable named company and assign it to an initial value "Coding For All". +company = 'Coding For All' +print (company), +print len(company), +print upper (company), +print lower(company), +company = text.capitalization +print (company) +company = text.title +print (company) +company = text.swapcase + + +#Cut(slice) out the first word of Coding For All string. +###text = "Python Programming" + +# Slice from index 0 to 6 (excluding 6) + #print(text[0:6]) # Output: Python + +# Slice from index 7 to end + #print(text[7:]) # Output: Programming + +# Slice with step + #print(text[::2]) # Output: Pto rgamn + +# Reverse the string + #print(text[::-1]) # Output: gnimmargorP nohtyP +### +text = 'Coding for all' +Slice from index 0 to 6 +ptint(text[0:6] + + +#Check if Coding For All string contains a word Coding using the method index, find or other methods. +text = 'Coding For All' +if 'Coding' in text: + print("Found using 'in'") + + +#Replace the word coding in the string 'Coding For All' to Python. +text 'Coding for all' +replace_text = text.replace ('Coding', 'Python') +print(replace_text) + + +Change Python for Everyone to Python for All using the replace method or other methods. +text 'Python for Everyone' +replace_python = text.replace ('Python', 'All') +print(replace_python + +Split the string 'Coding For All' using space as the separator (split()) . + + +"Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon" split the string at the comma. +What is the character at index 0 in the string Coding For All. +What is the last index of the string Coding For All. +What character is at index 10 in "Coding For All" string. +Create an acronym or an abbreviation for the name 'Python For Everyone'. +Create an acronym or an abbreviation for the name 'Coding For All'. +Use index to determine the position of the first occurrence of C in Coding For All. +Use index to determine the position of the first occurrence of F in Coding For All. +Use rfind to determine the position of the last occurrence of l in Coding For All People. +Use index or find to find the position of the first occurrence of the word 'because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction' +Use rindex to find the position of the last occurrence of the word because in the following sentence: 'You cannot end a sentence with because because because is a conjunction' +Slice out the phrase 'because because because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction' +Find the position of the first occurrence of the word 'because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction' +Slice out the phrase 'because because because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction' +Does ''Coding For All' start with a substring Coding? +Does 'Coding For All' end with a substring coding? +' Coding For All ' , remove the left and right trailing spaces in the given string. +Which one of the following variables return True when we use the method isidentifier(): +30DaysOfPython +thirty_days_of_python +The following list contains the names of some of python libraries: ['Django', 'Flask', 'Bottle', 'Pyramid', 'Falcon']. Join the list with a hash with space string. +Use the new line escape sequence to separate the following sentences. +I am enjoying this challenge. +I just wonder what is next. +Use a tab escape sequence to write the following lines. +Name Age Country City +Asabeneh 250 Finland Helsinki +Use the string formatting method to display the following: +radius = 10 +area = 3.14 * radius ** 2 +The area of a circle with radius 10 is 314 meters square. +Make the following using string formatting methods: +8 + 6 = 14 +8 - 6 = 2 +8 * 6 = 48 +8 / 6 = 1.33 +8 % 6 = 2 +8 // 6 = 1 +8 ** 6 = 262144