Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Waghraj1699 authored Aug 18, 2024
1 parent b83670e commit 62590bd
Show file tree
Hide file tree
Showing 4 changed files with 1,155 additions and 0 deletions.
294 changes: 294 additions & 0 deletions Day 19/Assignment_10B.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Zb-9TXtxZNGn",
"outputId": "094c0428-4720-472d-88d8-d4c972cd50d6"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"5\n",
" 1 \n",
" 2 2 \n",
" 3 3 \n",
" 4 4 \n",
"5 5 \n",
" 4 4 \n",
" 3 3 \n",
" 2 2 \n",
" 1 \n"
]
}
],
"source": [
"# Inverted Hollow Pyramid - 2\n",
"\n",
"n = int(input())\n",
"\n",
"for i in range(1 , n + 1):\n",
" if (i==1):\n",
" left_spaces = (\" \") * (2*(n - i))\n",
" row = left_spaces + (str(i) + \" \")\n",
" else:\n",
" left_spaces = (\" \") * (2*(n - i))\n",
" middle_spaces = (\" \") * (2*(i - 2))\n",
" row = left_spaces + (str(i) + \" \") + middle_spaces + (str(i) + \" \")\n",
" print(row)\n",
"\n",
"for i in range(1 , n):\n",
" if (i==(n - 1)):\n",
" left_spaces = (\" \") * (2*i)\n",
" row = left_spaces + (str(1) + \" \")\n",
" else:\n",
" left_spaces = (\" \") * (2*i)\n",
" middle_spaces = (\" \") * (2*(n - i) - 4)\n",
" row =left_spaces + (str(n - i) + \" \") + middle_spaces + (str(n - i) + \" \")\n",
"\n",
" print(row)"
]
},
{
"cell_type": "code",
"source": [
"# Two Triangles - 3\n",
"\n",
"n = int(input())\n",
"\n",
"for i in range(1 , n + 1):\n",
" if (i==1):\n",
" middle_spaces = (\" \") * (4*(n - i))\n",
" row = (\"* \") + middle_spaces + (\"* \")\n",
" elif (i==n):\n",
" row = (\"* \") * (2*n)\n",
" else:\n",
" left_spaces = (\" \") * (2*(i - 2))\n",
" middle_spaces = (\" \") * (4*(n - i))\n",
" right_spaces = (\" \") * (2*(i - 2))\n",
" row = (\"* \") + left_spaces + (\"* \") + middle_spaces + (\"* \") + right_spaces + (\"* \")\n",
" print(row)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "yHp0U8xdayIt",
"outputId": "729c4d4c-fc3a-4a34-de1a-e910b8561695"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"5\n",
"* * \n",
"* * * * \n",
"* * * * \n",
"* * * * \n",
"* * * * * * * * * * \n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Hollow Butterfly\n",
"\n",
"n = int(input())\n",
"\n",
"for i in range(1, n + 1):\n",
" if (i==1):\n",
" middle_spaces = (\" \") * (4*(n - i))\n",
" row = (\"* \") + middle_spaces + (\"* \")\n",
" else:\n",
" left_space = (\" \") * (2*(i - 2))\n",
" right_space = (\" \") * (2*(i - 2))\n",
" middle_spaces = (\" \") * (4*(n - i))\n",
" row = (\"* \") + left_space + (\"* \") + middle_spaces + (\"* \") + right_space + (\"* \")\n",
" print(row)\n",
"\n",
"for i in range(1 , n + 1):\n",
" if (i==n):\n",
" middle_spaces = (\" \") * (4*(i - 1))\n",
" row = (\"* \") + middle_spaces + (\"* \")\n",
" else:\n",
" left_space = (\" \") * (2*(n - i) - 2)\n",
" right_space = (\" \") * (2*(n - i) - 2)\n",
" middle_spaces = (\" \") * (4*(i - 1))\n",
" row = (\"* \") + left_space + (\"* \") + middle_spaces + (\"* \") + right_space + (\"* \")\n",
" print(row)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "lHYNGExPa8Qg",
"outputId": "14d28fc9-06f9-4d5c-8927-e0afca6dc0e0"
},
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"5\n",
"* * \n",
"* * * * \n",
"* * * * \n",
"* * * * \n",
"* * * * \n",
"* * * * \n",
"* * * * \n",
"* * * * \n",
"* * * * \n",
"* * \n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Perfect square in range\n",
"\n",
"a = int(input())\n",
"b = int(input())\n",
"count = 0\n",
"\n",
"for i in range(a , b + 1):\n",
" if int(i ** 0.5) ** 2 == i:\n",
" count = count + 1\n",
"\n",
"print(count)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "7vSAVmIrbKKe",
"outputId": "71dcc7e9-d9c8-4409-803b-c6b509cd75ad"
},
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"9\n",
"100\n",
"8\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Solid and Hollow Diamond\n",
"\n",
"n = int(input())\n",
"\n",
"for i in range(1 , n + 1):\n",
" stars = \"* \" * (i)\n",
" spaces = \" \" * (n - i)\n",
" row = spaces + stars\n",
" print(row)\n",
"\n",
"for i in range(1 , n):\n",
" if (i==n-1):\n",
" spaces = \" \" * (i)\n",
" row = spaces + (\"* \")\n",
" else:\n",
" left_spaces = (\" \") * i\n",
" middle_spaces = (\" \") * (2*(n - i) - 3)\n",
" row = left_spaces + (\"*\") + middle_spaces + (\"*\")\n",
" print(row)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "z5ZMQJ5vb3Jc",
"outputId": "20bd0479-8045-4554-e365-193066778bf5"
},
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"5\n",
" * \n",
" * * \n",
" * * * \n",
" * * * * \n",
"* * * * * \n",
" * *\n",
" * *\n",
" * *\n",
" * \n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Solid right Angled - 2\n",
"\n",
"n = int(input())\n",
"\n",
"for i in range(1 , n + 1 ):\n",
" stars = (\"* \") * i\n",
" spaces = (\" \") * (2*(n-i))\n",
" row = spaces + stars\n",
" print(row)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "YkITcZeob_oI",
"outputId": "52ae9409-0f4a-4707-f785-721ab7f9e35a"
},
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"5\n",
" * \n",
" * * \n",
" * * * \n",
" * * * * \n",
"* * * * * \n"
]
}
]
}
]
}
Loading

0 comments on commit 62590bd

Please sign in to comment.