{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "10\n", "10\n", "10\n", "8\n" ] } ], "source": [ "# # Get n and m from first line\n", "# n, m = map(int, input().split())\n", "# print(f\"n={n}, m={m}\") # Debug print\n", "\n", "# # Initialize empty array for the grid\n", "# array = []\n", "\n", "# # Read n lines\n", "# for i in range(n):\n", "# arr2 = input().split(\",\")\n", "# array.append(arr2)\n", "# print(f\"Row {i}: {arr2}\") # Debug print\n", "\n", "# print(\"Full array:\", array) # Debug print\n", "\n", "# # Search for row with exactly m stars\n", "# for row in array:\n", "# star_count = row.count(\"*\")\n", "# print(f\"Checking row {row}, star count: {star_count}\") # Debug print\n", "# if star_count == m:\n", "# print(\"Found matching row:\", row)\n", "# break\n", "\n", "\n", "\n", "\n", "\n", "# x='**********.......***87675654534343*******************************'\n", "\n", "\n", "# print(x.count('*'))\n", "\n", "x=[['**********'], ['**********'], ['**********'], ['********']]\n", "\n", "for i in x :\n", " count = i[0].count('*')\n", " print(count)\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "class Solve:\n", " def toolong(word:str)->None:\n", " \n", " \n", " x:int=word.__len__()\n", "\n", " if x>10:\n", " finalword=f'{word[:1]}{x-2}{word[-1:]}'\n", " print(finalword)\n", " else:\n", " print(word)\n", "\n", "\n", "\n", "\n", "if __name__ == '__main__':\n", " testcase:int=int(input())\n", " for i in range(testcase):\n", " word:str=str(input())\n", " Solve.toolong(word)\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0]\n", "1\n" ] } ], "source": [ "list1=[int(x) for x in input().split(',')][:5]\n", "list1.count(0)\n", "print(list1)\n", "print(list1.count(0))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1 2 3 4 \n", "\n", "5 6 7 8 \n", "\n", "9 10 11 12 \n", "\n", "13 14 15 16 \n", "\n" ] } ], "source": [ "n=4\n", "counter=1\n", "for i in range(n):\n", " for j in range(n):\n", " print(counter,end=\" \")\n", " counter+=1\n", " print('\\n')\n", " \n" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " \n", " A\n", " BB\n", " CCC\n", " DDDD\n", " EEEEE\n", " FFFFFF\n", " GGGGGGG\n", " HHHHHHHH\n", " IIIIIIIII\n", "A\n" ] } ], "source": [ "n=9\n", "a=64\n", "\n", "for i in range(n+1):\n", " print(\" \"*(n-i),chr(a)*i)\n", " a+=1\n", "\n", "\n", "print(chr(65))" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 1\n", "\n", " 2 3\n", "\n", " 4 5 6\n", "\n", " 7 8 9 10\n", "\n", " 11 12 13 14 15\n", "\n" ] } ], "source": [ "n=5\n", "number=1\n", "\n", "\n", "for i in range(n):\n", " for j in range(i+1):\n", " print(\" \"*(n-j),end=str(number))\n", " number+=1\n", " print('\\n')\n" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 1\n", "\n", " 2 3\n", "\n", " 4 5 6\n", "\n", " 7 8 9 10\n", "\n", " 11 12 13 14 15\n", "\n" ] } ], "source": [ "n=5\n", "number=1\n", "\n", "\n", "for i in range(n):\n", " for j in range(i+1):\n", " print(\" \"*(n-i),end=str(number))\n", " number+=1\n", " print('\\n')\n" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1 \n", "\n", "2 3 \n", "\n", "4 5 6 \n", "\n", "7 8 9 10 \n", "\n", "11 12 13 14 15 \n", "\n" ] } ], "source": [ "n=5\n", "number=1\n", "\n", "\n", "for i in range(n):\n", " for j in range(i+1):\n", " print(number,end=\" \")\n", " number+=1\n", " print('\\n')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# n=5\n", "# number=1\n", "# for i in range(n+1):\n", "# print(\" \"number*n-1)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "10\n", "121\n", "1232\n", "12343\n" ] } ], "source": [ " ## Uclide Peramide\n", "\n", "rows=4\n", "pattern = []\n", "for i in range(1, rows + 1):\n", " row = \"\"\n", " for j in range(1, i + 1):\n", " row += str(j)\n", " row += str(i - 1)[::-1] \n", " pattern.append(row)\n", "\n", "\n", "for row in pattern:\n", " print(row)\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 1 12 1 123 211234 321" ] } ], "source": [ "# Holo Dimond print\n", "n = 4\n", "\n", "for i in range(n):\n", " # Print spaces for the top part\n", " for j in range(n - i - 1):\n", " print(\" \", end=\"\")\n", "\n", " # Print numbers for the top part\n", " for j in range(i + 1):\n", " print(j + 1, end=\"\")\n", "\n", " # Print spaces for the bottom part (if not the first row)\n", " if i != 0:\n", " for j in range(2 * i - 1):\n", " print(\" \", end=\"\")\n", "\n", " # Print numbers for the bottom part (if not the first row)\n", " if i != 0:\n", " for j in range(i, 0, -1):\n", " print(j, end=\"\")" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n" ] } ], "source": [ "n=[1]\n", "print(len(n))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.11.8" } }, "nbformat": 4, "nbformat_minor": 2 }