Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
milaan9 authored Aug 24, 2021
1 parent a4ad856 commit 0cf7b7c
Showing 1 changed file with 138 additions and 0 deletions.
138 changes: 138 additions & 0 deletions 11 read a num n and print the series 1+2+...+n=.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<small><small><i>\n",
"All the IPython Notebooks in this example series by Dr. Milan Parmar are available @ **[GitHub](https://github.com/milaan9/90_Python_Examples)**\n",
"</i></small></small>"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enter a number: 5\n",
"1 + 2 + 3 + 4 + 5 = 15\n",
"\n"
]
},
{
"data": {
"text/plain": [
"'\\n>>Output/Runtime Test Cases\\n \\nCase 1:\\nEnter a number: 4\\n1 + 2 + 3 + 4 = 10\\n \\nCase 2:\\nEnter a number: 5\\n1 + 2 + 3 + 4 + 5 = 15\\n'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Here is source code of the Python Program to ...\n",
"# The program output is also shown below.\n",
"\n",
"n=int(input(\"Enter a number: \"))\n",
"a=[]\n",
"for i in range(1,n+1):\n",
" print(i,sep=\" \",end=\" \")\n",
" if(i<n):\n",
" print(\"+\",sep=\" \",end=\" \")\n",
" a.append(i)\n",
"print(\"=\",sum(a))\n",
" \n",
"print()\n",
"\n",
"\n",
"'''\n",
">>Output/Runtime Test Cases\n",
" \n",
"Case 1:\n",
"Enter a number: 4\n",
"1 + 2 + 3 + 4 = 10\n",
" \n",
"Case 2:\n",
"Enter a number: 5\n",
"1 + 2 + 3 + 4 + 5 = 15\n",
"'''"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"hide_input": false,
"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.8.8"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit 0cf7b7c

Please sign in to comment.