130 lines
2.3 KiB
Text
130 lines
2.3 KiB
Text
![]() |
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Q2"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"key exists\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"dict = {'Rafay' : 3.3, 'Hassan' : 3.7, 'Isham' : 4.8}\n",
|
||
|
"\n",
|
||
|
"key = input('Enter key')\n",
|
||
|
"\n",
|
||
|
"if dict.get(key) is None :\n",
|
||
|
" print('key does not exist')\n",
|
||
|
"else:\n",
|
||
|
" print('key exists')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Q3"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"basicPay = int(input('Enter basic pay'))\n",
|
||
|
"\n",
|
||
|
"if basicPay < 30000 :\n",
|
||
|
" houseRent = 0.3 * basicPay\n",
|
||
|
"elif basicPay >= 30000 and basicPay <= 50000 :\n",
|
||
|
" houseRent = 0.4 * basicPay\n",
|
||
|
"else:\n",
|
||
|
" houseRent = 0.5 * basicPay\n",
|
||
|
"\n",
|
||
|
"netPay = basicPay + houseRent\n",
|
||
|
"\n",
|
||
|
"print('Basic Pay', basicPay)\n",
|
||
|
"print('House Rent', houseRent)\n",
|
||
|
"print('Net Pay', netPay)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Q4"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"minNum = None\n",
|
||
|
"for i in range(3):\n",
|
||
|
" num = input('Enter a number')\n",
|
||
|
" if minNum is None or num < minNum :\n",
|
||
|
" minNum = num\n",
|
||
|
"\n",
|
||
|
"print(minNum)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Q5"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"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.12.4"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|