Created
October 8, 2019 15:57
-
-
Save Pabla007/ce72f41abeb97a5c3869a2edd8891f35 to your computer and use it in GitHub Desktop.
Practical
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Practical Set 5 1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([4.572 , 5.461 , 4.4704, 3.81 , 4.5974, 5.3086])" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"Height_list=[180,215,176,150,181,209]\n", | |
"nparr=np.array(Height_list,dtype=None)\n", | |
"nparr=nparr*0.0254\n", | |
"nparr" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"['T',\n", | |
" '__abs__',\n", | |
" '__add__',\n", | |
" '__and__',\n", | |
" '__array__',\n", | |
" '__array_finalize__',\n", | |
" '__array_function__',\n", | |
" '__array_interface__',\n", | |
" '__array_prepare__',\n", | |
" '__array_priority__',\n", | |
" '__array_struct__',\n", | |
" '__array_ufunc__',\n", | |
" '__array_wrap__',\n", | |
" '__bool__',\n", | |
" '__class__',\n", | |
" '__complex__',\n", | |
" '__contains__',\n", | |
" '__copy__',\n", | |
" '__deepcopy__',\n", | |
" '__delattr__',\n", | |
" '__delitem__',\n", | |
" '__dir__',\n", | |
" '__divmod__',\n", | |
" '__doc__',\n", | |
" '__eq__',\n", | |
" '__float__',\n", | |
" '__floordiv__',\n", | |
" '__format__',\n", | |
" '__ge__',\n", | |
" '__getattribute__',\n", | |
" '__getitem__',\n", | |
" '__gt__',\n", | |
" '__hash__',\n", | |
" '__iadd__',\n", | |
" '__iand__',\n", | |
" '__ifloordiv__',\n", | |
" '__ilshift__',\n", | |
" '__imatmul__',\n", | |
" '__imod__',\n", | |
" '__imul__',\n", | |
" '__index__',\n", | |
" '__init__',\n", | |
" '__init_subclass__',\n", | |
" '__int__',\n", | |
" '__invert__',\n", | |
" '__ior__',\n", | |
" '__ipow__',\n", | |
" '__irshift__',\n", | |
" '__isub__',\n", | |
" '__iter__',\n", | |
" '__itruediv__',\n", | |
" '__ixor__',\n", | |
" '__le__',\n", | |
" '__len__',\n", | |
" '__lshift__',\n", | |
" '__lt__',\n", | |
" '__matmul__',\n", | |
" '__mod__',\n", | |
" '__mul__',\n", | |
" '__ne__',\n", | |
" '__neg__',\n", | |
" '__new__',\n", | |
" '__or__',\n", | |
" '__pos__',\n", | |
" '__pow__',\n", | |
" '__radd__',\n", | |
" '__rand__',\n", | |
" '__rdivmod__',\n", | |
" '__reduce__',\n", | |
" '__reduce_ex__',\n", | |
" '__repr__',\n", | |
" '__rfloordiv__',\n", | |
" '__rlshift__',\n", | |
" '__rmatmul__',\n", | |
" '__rmod__',\n", | |
" '__rmul__',\n", | |
" '__ror__',\n", | |
" '__rpow__',\n", | |
" '__rrshift__',\n", | |
" '__rshift__',\n", | |
" '__rsub__',\n", | |
" '__rtruediv__',\n", | |
" '__rxor__',\n", | |
" '__setattr__',\n", | |
" '__setitem__',\n", | |
" '__setstate__',\n", | |
" '__sizeof__',\n", | |
" '__str__',\n", | |
" '__sub__',\n", | |
" '__subclasshook__',\n", | |
" '__truediv__',\n", | |
" '__xor__',\n", | |
" 'all',\n", | |
" 'any',\n", | |
" 'argmax',\n", | |
" 'argmin',\n", | |
" 'argpartition',\n", | |
" 'argsort',\n", | |
" 'astype',\n", | |
" 'base',\n", | |
" 'byteswap',\n", | |
" 'choose',\n", | |
" 'clip',\n", | |
" 'compress',\n", | |
" 'conj',\n", | |
" 'conjugate',\n", | |
" 'copy',\n", | |
" 'ctypes',\n", | |
" 'cumprod',\n", | |
" 'cumsum',\n", | |
" 'data',\n", | |
" 'diagonal',\n", | |
" 'dot',\n", | |
" 'dtype',\n", | |
" 'dump',\n", | |
" 'dumps',\n", | |
" 'fill',\n", | |
" 'flags',\n", | |
" 'flat',\n", | |
" 'flatten',\n", | |
" 'getfield',\n", | |
" 'imag',\n", | |
" 'item',\n", | |
" 'itemset',\n", | |
" 'itemsize',\n", | |
" 'max',\n", | |
" 'mean',\n", | |
" 'min',\n", | |
" 'nbytes',\n", | |
" 'ndim',\n", | |
" 'newbyteorder',\n", | |
" 'nonzero',\n", | |
" 'partition',\n", | |
" 'prod',\n", | |
" 'ptp',\n", | |
" 'put',\n", | |
" 'ravel',\n", | |
" 'real',\n", | |
" 'repeat',\n", | |
" 'reshape',\n", | |
" 'resize',\n", | |
" 'round',\n", | |
" 'searchsorted',\n", | |
" 'setfield',\n", | |
" 'setflags',\n", | |
" 'shape',\n", | |
" 'size',\n", | |
" 'sort',\n", | |
" 'squeeze',\n", | |
" 'std',\n", | |
" 'strides',\n", | |
" 'sum',\n", | |
" 'swapaxes',\n", | |
" 'take',\n", | |
" 'tobytes',\n", | |
" 'tofile',\n", | |
" 'tolist',\n", | |
" 'tostring',\n", | |
" 'trace',\n", | |
" 'transpose',\n", | |
" 'var',\n", | |
" 'view']" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dir(nparr)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Practical Set 5 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([False, False, True, False, True])" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"BMI = [21,23,19,24,20]\n", | |
"b=np.array(BMI)\n", | |
"b<21" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Practical Set 5 3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Mean of girl is : 181.66666666666666\n", | |
"Mean of Boy is 188.66666666666666\n" | |
] | |
} | |
], | |
"source": [ | |
"Height = [180,215,176,150,181,209]\n", | |
"Gender = [\"GIRL\", \"GIRL\",\"BOY\", \"GIRL\", \"BOY\", \"BOY\"]\n", | |
"girl=[]\n", | |
"boy=[]\n", | |
"for i in range(len(Gender)):\n", | |
" if(Gender[i]==\"GIRL\"):\n", | |
" girl.append(Height[i])\n", | |
" else:\n", | |
" boy.append(Height[i])\n", | |
"#print(Gender[0])\n", | |
"g=np.array(girl)\n", | |
"b=np.array(boy)\n", | |
"gmean=g.mean()\n", | |
"bmean=b.mean()\n", | |
"print(\"Mean of girl is :\",gmean)\n", | |
"print(\"Mean of Boy is \",bmean)\n", | |
"#dir(g)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Median of girls is : 180.0\n", | |
"Median of boys is : 181.0\n" | |
] | |
} | |
], | |
"source": [ | |
"gm=np.array(girl)\n", | |
"g=np.median(gm)\n", | |
"bm=np.array(boy)\n", | |
"b=np.median(bm)\n", | |
"print(\"Median of girls is : \", g)\n", | |
"print(\"Median of boys is : \", b)\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Practical 5 7" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[[28 27 17]\n", | |
" [58 66 32]\n", | |
" [44 51 37]]\n" | |
] | |
} | |
], | |
"source": [ | |
"mat1=([1,3,2],[1,6,8],[5,2,1])\n", | |
"mat2=([6,8,6],[6,3,3],[2,5,1])\n", | |
"result=np.dot(mat1,mat2)\n", | |
"print(result)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Practical Set 6" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Practical Set 6 1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import turtle" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"turtle.setup(800,600)\n", | |
"board=turtle.Turtle()\n", | |
"\n", | |
"for i in range(1,20):\n", | |
" board.circle(i*6)\n", | |
"turtle.done()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Practical 6 3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from tkinter import *\n", | |
"from tkinter.ttk import Combobox" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"window=Tk()\n", | |
"var = StringVar()\n", | |
"var.set(\"one\")\n", | |
"data=(\"one\", \"two\", \"three\", \"four\")\n", | |
"cb=Combobox(window, values=data)\n", | |
"cb.place(x=60, y=150)\n", | |
"\n", | |
"lb=Listbox(window, height=5, selectmode='multiple')\n", | |
"for num in data:\n", | |
" lb.insert(END,num)\n", | |
"lb.place(x=250, y=150)\n", | |
"\n", | |
"v0=IntVar()\n", | |
"v0.set(1)\n", | |
"r1=Radiobutton(window, text=\"male\", variable=v0,value=1)\n", | |
"r2=Radiobutton(window, text=\"female\", variable=v0,value=2)\n", | |
"r1.place(x=100,y=50)\n", | |
"r2.place(x=180, y=50)\n", | |
" \n", | |
"v1 = IntVar()\n", | |
"v2 = IntVar()\n", | |
"C1 = Checkbutton(window, text = \"Cricket\", variable = v1)\n", | |
"C2 = Checkbutton(window, text = \"Tennis\", variable = v2)\n", | |
"C1.place(x=100, y=100)\n", | |
"C2.place(x=180, y=100)\n", | |
"\n", | |
"window.title('Hello Python')\n", | |
"window.geometry(\"400x300+10+10\")\n", | |
"window.mainloop()" | |
] | |
} | |
], | |
"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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment