From 13140b548e89840bcd11f24a83fc06fe294502b8 Mon Sep 17 00:00:00 2001 From: sabrinakreyzerman-k Date: Thu, 7 May 2026 21:34:09 -0400 Subject: [PATCH] Revert "Completed Day 2 Exercises for Day 2 of Python training" --- day_2_exercise.ipynb | 674 ------------------------------------------- 1 file changed, 674 deletions(-) delete mode 100644 day_2_exercise.ipynb diff --git a/day_2_exercise.ipynb b/day_2_exercise.ipynb deleted file mode 100644 index 67e83f3..0000000 --- a/day_2_exercise.ipynb +++ /dev/null @@ -1,674 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "provenance": [], - "authorship_tag": "ABX9TyMa8YPjzaqegnO+MU5w1IPg", - "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": "markdown", - "source": [ - "# Day 2 Exercises" - ], - "metadata": { - "id": "-DMChIjQDZSr" - } - }, - { - "cell_type": "markdown", - "source": [ - "## Strings" - ], - "metadata": { - "id": "4xH2QNgEDcHS" - } - }, - { - "cell_type": "markdown", - "source": [ - "1. Given string contains a combination of the lower and upper case letters. Write a program to arrange the characters of a string so that all lowercase letters should come first." - ], - "metadata": { - "id": "nfjIz4cvDfD0" - } - }, - { - "cell_type": "code", - "source": [ - "def arrange_letters(str) :\n", - " lowercase = \"\"\n", - " uppercase = \"\"\n", - " for i in str :\n", - " if i.islower() :\n", - " lowercase += i\n", - " else :\n", - " uppercase += i\n", - " return lowercase + uppercase\n", - "\n", - "print(arrange_letters(\"saBrINa\"))" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "qdPMCDGAHy4G", - "outputId": "223571e0-33af-4c4d-d6e6-e668914e398e" - }, - "execution_count": 43, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "saraBIN\n" - ] - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "2. Write a program to check if two strings are balanced. For example, strings s1 and s2 are balanced if all the characters in the s1 are present in s2. The character's position doesn't matter" - ], - "metadata": { - "id": "J49l26buDl4w" - } - }, - { - "cell_type": "code", - "source": [ - "def is_balanced(s1, s2) :\n", - " for i in s1 :\n", - " if i not in s2 :\n", - " return False\n", - " return True" - ], - "metadata": { - "id": "Rx2sqxsXHzoi" - }, - "execution_count": 45, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "def is_balanced(s1, s2) :\n", - " for i in s1 :\n", - " if i in s2 :\n", - " return True\n", - " else :\n", - " return False\n", - "\n", - "print(is_balanced(\"Kr\", \"SabrinaKreyz\"))" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "collapsed": true, - "id": "GxbXtnJSMG5_", - "outputId": "287bbee7-45f1-4972-8cd7-0d56df2f9f72" - }, - "execution_count": 49, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "True\n" - ] - } - ] - }, - { - "cell_type": "code", - "source": [ - "print(is_balanced(\"Kr\", \"Sabrina\"))" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "ftNLsjL_MlVl", - "outputId": "29140efb-ce23-41a1-98a0-c47a04148ca9" - }, - "execution_count": 51, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "False\n" - ] - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "## Converting types" - ], - "metadata": { - "id": "GeNjjqgODszZ" - } - }, - { - "cell_type": "markdown", - "source": [ - "1. Convert the following to strings" - ], - "metadata": { - "id": "5xHSrTqPDvWq" - } - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "tiFTccjgDH9_", - "outputId": "8d266aa7-df60-4226-f9dc-b3d9e96036a8" - }, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "4.5" - ] - }, - "metadata": {}, - "execution_count": 1 - } - ], - "source": [ - "9 / 2" - ] - }, - { - "cell_type": "code", - "source": [ - "str(9 / 2)" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 35 - }, - "id": "TLIK1JKIEBk3", - "outputId": "bcc7570c-ae64-4b95-c5ea-28c93301003c" - }, - "execution_count": 4, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "'4.5'" - ], - "application/vnd.google.colaboratory.intrinsic+json": { - "type": "string" - } - }, - "metadata": {}, - "execution_count": 4 - } - ] - }, - { - "cell_type": "code", - "source": [ - "9 // -2" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "HJWb-o1QD488", - "outputId": "39b852ea-d17f-447f-f413-2340f13e82ef" - }, - "execution_count": 2, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "-5" - ] - }, - "metadata": {}, - "execution_count": 2 - } - ] - }, - { - "cell_type": "code", - "source": [ - "str(9 // -2)" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 35 - }, - "id": "28mhCtKnEJl3", - "outputId": "5e7a7c9e-c574-4b2f-9047-89d5ed295399" - }, - "execution_count": 5, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "'-5'" - ], - "application/vnd.google.colaboratory.intrinsic+json": { - "type": "string" - } - }, - "metadata": {}, - "execution_count": 5 - } - ] - }, - { - "cell_type": "code", - "source": [ - "1.5 * 2 >= 7 - 3" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "EOJIo-WED9OJ", - "outputId": "51126a6d-e6f5-4817-99c8-319cdb72b5f5" - }, - "execution_count": 3, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "False" - ] - }, - "metadata": {}, - "execution_count": 3 - } - ] - }, - { - "cell_type": "code", - "source": [ - "str(1.5 * 2 >= 7 - 3)" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 35 - }, - "id": "UDw2d6bLEWpl", - "outputId": "29b50d9d-8064-4dda-c5d3-ea512629d0b9" - }, - "execution_count": 6, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "'False'" - ], - "application/vnd.google.colaboratory.intrinsic+json": { - "type": "string" - } - }, - "metadata": {}, - "execution_count": 6 - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "2. Convert the following to an integer or float" - ], - "metadata": { - "id": "JVXt882EEb7V" - } - }, - { - "cell_type": "code", - "source": [ - "\"17\"" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 35 - }, - "id": "GveaCnlDEep1", - "outputId": "39127740-656e-4556-80e5-76ab12ff1086" - }, - "execution_count": 7, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "'17'" - ], - "application/vnd.google.colaboratory.intrinsic+json": { - "type": "string" - } - }, - "metadata": {}, - "execution_count": 7 - } - ] - }, - { - "cell_type": "code", - "source": [ - "float(17)" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "vM92CFdbEk_X", - "outputId": "c78d8d8c-a99c-4d40-c943-57709ef97472" - }, - "execution_count": 10, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "17.0" - ] - }, - "metadata": {}, - "execution_count": 10 - } - ] - }, - { - "cell_type": "code", - "source": [ - "\"51\"" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 35 - }, - "id": "mOc5QzJ7EgT3", - "outputId": "7bd37cda-21e3-4bdd-ab23-9e89e2e93727" - }, - "execution_count": 8, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "'51'" - ], - "application/vnd.google.colaboratory.intrinsic+json": { - "type": "string" - } - }, - "metadata": {}, - "execution_count": 8 - } - ] - }, - { - "cell_type": "code", - "source": [ - "float(51)" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "2EDQomCeEouY", - "outputId": "c61f67ce-9eb5-417b-d00b-fdff836fce61" - }, - "execution_count": 11, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "51.0" - ] - }, - "metadata": {}, - "execution_count": 11 - } - ] - }, - { - "cell_type": "code", - "source": [ - "\"3.175\"" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 35 - }, - "id": "SnqfIk7fEiDW", - "outputId": "accbfe09-f32c-4638-d08a-0ccfcc419b4b" - }, - "execution_count": 9, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "'3.175'" - ], - "application/vnd.google.colaboratory.intrinsic+json": { - "type": "string" - } - }, - "metadata": {}, - "execution_count": 9 - } - ] - }, - { - "cell_type": "code", - "source": [ - "int(3.175)" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "1UvJXDJ5EqRi", - "outputId": "f4158943-38ef-4ab1-9a53-61235b7e88c9" - }, - "execution_count": 12, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "3" - ] - }, - "metadata": {}, - "execution_count": 12 - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "## Input" - ], - "metadata": { - "id": "49-UddINEt_N" - } - }, - { - "cell_type": "markdown", - "source": [ - "1. Write a Python program that asks the user for their name using the input() function and then greets them with a personalized message. Ensure that the program displays the user's name exactly as entered." - ], - "metadata": { - "id": "UxSpa42IEv-L" - } - }, - { - "cell_type": "code", - "source": [ - "def personal_greeting() :\n", - " name = input(\"What is your name?\")\n", - " print(f\"Good morning, {name}!\")" - ], - "metadata": { - "id": "1gy4rU50E6Nh" - }, - "execution_count": 20, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "personal_greeting()" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "HYm4CZqDGJTd", - "outputId": "8b62902a-16e1-4f94-98b6-f87ee2a5282c" - }, - "execution_count": 21, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "What is your name?Sabrina\n", - "Good morning, Sabrina!\n" - ] - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "2. Write a program to accept two integer numbers from the user and calculate their product (multiplication)." - ], - "metadata": { - "id": "h62vFcjdE20k" - } - }, - { - "cell_type": "code", - "source": [ - "def calculate_product() :\n", - " first_number = int(input(\"Enter the first number.\"))\n", - " second_number = int(input(\"Enter the second number.\"))\n", - " print(f\"The product of {first_number} and {second_number} is {first_number * second_number}\")" - ], - "metadata": { - "collapsed": true, - "id": "RMd0IvR8Evm4" - }, - "execution_count": 25, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "calculate_product()" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "vs4UUzv9G2he", - "outputId": "ec8d6bbd-b2ad-4a5a-ae28-ec92046a3780" - }, - "execution_count": 26, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Enter the first number.3\n", - "Enter the second number.4\n", - "The product of 3 and 4 is 12\n" - ] - } - ] - }, - { - "cell_type": "code", - "source": [ - "def display_product() :\n", - " first_number = int(input(\"Enter the first number.\"))\n", - " second_number = int(input(\"Enter the second number.\"))\n", - " print(f\"{first_number * second_number}\")" - ], - "metadata": { - "id": "D36-KuueHDKN" - }, - "execution_count": 27, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "display_product()" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "GyNQz4eDHJ5y", - "outputId": "15695cda-355d-4d21-918d-d55fa59da212" - }, - "execution_count": 30, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Enter the first number.3\n", - "Enter the second number.4\n", - "12\n" - ] - } - ] - } - ] -} \ No newline at end of file