Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
395 changes: 395 additions & 0 deletions fun.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,395 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'aBc'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Toggle case\n",
"#s=input()\n",
"def togglestring(s):\n",
" s=list(s)\n",
" t=[]\n",
" for i in s:\n",
" if i.islower():\n",
" t.append(i.upper())\n",
" else:\n",
" t.append(i.lower())\n",
" return \"\".join(t)\n",
"togglestring(\"AbC\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#Duration\n",
"Input: start Time,End Time (HH MM)\n",
" HH-{00,23} -- {00 00,23 59}\n",
" mm-{00,59}\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 44 2 14\n"
]
},
{
"ename": "ValueError",
"evalue": "invalid literal for int() with base 10: '1 44 2 14'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-6-db59fa031fe2>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;31m#calculate the total minutes into HH MM\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mn\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 5\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mminutedifferenece\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[0msh\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: '1 44 2 14'"
]
}
],
"source": [
"#Calculate the time difference as total number of minutes\n",
"#calculate the total minutes into HH MM\n",
"\n",
"n=int(input())\n",
"def minutedifferenece():\n",
" sh=int(s[0])\n",
" sm=int(s[1])\n",
" eh=int(s[2])\n",
" em=int(s[3])\n",
" startminutes=(sh * 60)+ sm\n",
" endminutes=(eh*60)+em\n",
" return endminutes-startminutes\n",
"def outputtimeformat(minutes):\n",
" hh=minutes//60\n",
" mm=minutes%60\n",
" print(hh,mm)\n",
" return\n",
"for i in range(0,n):\n",
" s=input()\n",
" minutes=minutedifferenece(s)\n",
" outputtimeformat(minutes)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7\n",
"7\n",
"1\n",
"NO\n",
"2\n",
"1\n",
"NO\n",
"3\n",
"1\n",
"NO\n",
"4\n",
"3\n",
"NO\n",
"7\n",
"1\n",
"NO\n",
"8\n",
"7\n",
"NO\n",
"9\n",
"4\n",
"NO\n"
]
}
],
"source": [
"n=int(input())\n",
"\n",
"def perfect(z):\n",
" sum=0\n",
" for j in range(1,z):\n",
" if z%j==0:\n",
" sum=sum+j \n",
" if (sum)==z:\n",
" print(\"Yes\")\n",
" else:\n",
" print(\"NO\")\n",
"\n",
"for i in range(n):\n",
" z=int(input())\n",
" perfect(z)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1234567890\n"
]
},
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"n=int(input())\n",
"z=n\n",
"c=len(str(z))\n",
"c"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"102356412345\n",
"Illegal ISBN\n"
]
}
],
"source": [
"n=int(input())\n",
"z=n\n",
"c=len(str(z))\n",
"sum=0\n",
"if c==10:\n",
" i=10\n",
" while(i!=0):\n",
" sum=sum+i*(n%10)\n",
" n=n//10\n",
" i=i-1 \n",
" if sum%11==0:\n",
" print(\"Legal ISBN\")\n",
" else:\n",
" print(\"Illegal ISBN\")\n",
"else:\n",
" print(\"Illegal ISBN\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"'''\n",
"# Sample code to perform I/O:\n",
"\n",
"name = input() # Reading input from STDIN\n",
"print('Hi, %s.' % name) # Writing output to STDOUT\n",
"\n",
"# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n",
"'''\n",
"\n",
"# Write your code here\n",
"n=int(input())\n",
"\n",
"def seating(s):\n",
" r=s%12\n",
" if(r==1):\n",
" print(s+11,\" WS\")\n",
" elif(r==2):\n",
" print(s+9,\" MS\")\n",
" elif(r==3):\n",
" print(s+7,\" AS\")\n",
" elif(r==4):\n",
" print(s+5,\" AS\")\n",
" elif(r==5):\n",
" print(s+3,\" MS\")\n",
" elif(r==6):\n",
" print(s+1,\" WS\")\n",
" elif(r==7):\n",
" print(s-1,\" WS\")\n",
" elif(r==8):\n",
" print(s-3,\" MS\")\n",
" elif(r==9):\n",
" print(s-5,\" AS\")\n",
" elif(r==10):\n",
" print(s-7,\" AS\")\n",
" elif(r==11):\n",
" print(s-9,\" MS\")\n",
" elif(r==0):\n",
" print(s-11,\" WS\")\n",
"\n",
"\n",
"for i in range(n):\n",
" s=int(input())\n",
" seating(s)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n",
"100\n",
"110\n",
"NO\n"
]
}
],
"source": [
"'''\n",
"# Sample code to perform I/O:\n",
"\n",
"name = input() # Reading input from STDIN\n",
"print('Hi, %s.' % name) # Writing output to STDOUT\n",
"\n",
"# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n",
"'''\n",
"\n",
"# Write your code here\n",
"n=int(input())\n",
"s=int(input())\n",
"\n",
"def skill(s,d):\n",
" if(s>=d):\n",
" print(\"YES\")\n",
" else:\n",
" print(\"NO\")\n",
"\n",
"for i in range(n):\n",
" d=int(input())\n",
" skill(s,d)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12E222-22\n"
]
},
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s=input()\n",
"\n",
"z=len(s)\n",
"z"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (<ipython-input-3-46b93d421806>, line 15)",
"output_type": "error",
"traceback": [
"\u001b[1;36m File \u001b[1;32m\"<ipython-input-3-46b93d421806>\"\u001b[1;36m, line \u001b[1;32m15\u001b[0m\n\u001b[1;33m if(((s[0]+s[1])%2==0 and (s[3]+s[4])%2==0 and (s[4]+s[5])%2==0 and (s[7]+s[8])%2==0 and (s[6]=='-')) and (s[2]!='A' or s[2]!='E' or s[2]!='I' s[2]!='O'or s[2]!='U')):\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": [
"'''\n",
"# Sample code to perform I/O:\n",
"\n",
"name = input() # Reading input from STDIN\n",
"print('Hi, %s.' % name) # Writing output to STDOUT\n",
"\n",
"# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n",
"'''\n",
"\n",
"# Write your code here\n",
"s=input()\n",
"\n",
"z=len(s)\n",
"if z==9:\n",
" if(((s[0]+s[1])%2==0 and (s[3]+s[4])%2==0 and (s[4]+s[5])%2==0 and (s[7]+s[8])%2==0 and (s[6]=='-')) and (s[2]!='A' or s[2]!='E' or s[2]!='I' s[2]!='O'or s[2]!='U')):\n",
" print(\"valid\")\n",
" else:\n",
" print(\"invalid\")\n",
"else:\n",
" print(\"invalid\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}