|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Learn Python - Beginners Exercise : Variables\n", |
| 8 | + "\n", |
| 9 | + "The best way we learn any programming language is by practicing. We have created these exercises for people who would want to get a good command over Python programming language.\n", |
| 10 | + "\n", |
| 11 | + "Beginner's exercises are for all those beginners who are just starting to learn Python, and for those who would want to test their python programming skill.\n", |
| 12 | + "Use your \n", |
| 13 | + "\n", |
| 14 | + "### Practice and know where you stand.\n", |
| 15 | + "\n", |
| 16 | + "**Hope, these exercises help you to improve your Python coding skills.**\n", |
| 17 | + "\n", |
| 18 | + "_This page keeps growing. We keep adding questions to each exercise notebook. If you have any exercises that we have not covered, feel free to share it with us._\n", |
| 19 | + "\n", |
| 20 | + "#### Use our telegram group [Python Programmers](https://t.me/python_programmers_club) to share any exercises that you have or get your questions answered.\n", |
| 21 | + "\n", |
| 22 | + "Good solutions will be uploaded into our code base." |
| 23 | + ] |
| 24 | + }, |
| 25 | + { |
| 26 | + "attachments": {}, |
| 27 | + "cell_type": "markdown", |
| 28 | + "metadata": {}, |
| 29 | + "source": [ |
| 30 | + "1. Write a Python program to get the Python version you are using." |
| 31 | + ] |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "markdown", |
| 35 | + "metadata": {}, |
| 36 | + "source": [ |
| 37 | + "2. Create a variable named `total` and assign sum of 234 and 456 to it to it. Print the value in `total`." |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "cell_type": "markdown", |
| 42 | + "metadata": {}, |
| 43 | + "source": [ |
| 44 | + "3. To the above code, add the comment explaining what the code does. Use all the different commenting options available in Python." |
| 45 | + ] |
| 46 | + }, |
| 47 | + { |
| 48 | + "cell_type": "markdown", |
| 49 | + "metadata": {}, |
| 50 | + "source": [ |
| 51 | + "4. Create a variable named `num` and assign any odd number to it with decimals (float)" |
| 52 | + ] |
| 53 | + }, |
| 54 | + { |
| 55 | + "cell_type": "markdown", |
| 56 | + "metadata": {}, |
| 57 | + "source": [ |
| 58 | + "5. Create a small program. Create the following variables.\n", |
| 59 | + " 1. Create a variable named `name` and assign your name to it . (type str) \n", |
| 60 | + " 2. Create a variable named `age` and assign your age to it (type int) \n", |
| 61 | + " 3. Create a variable named `address` and assign your address to it (type str)\n", |
| 62 | + " 4. Create a variable named `salary` and assign a value to it (type float)\n", |
| 63 | + " 5. Print the values in the variable, concatenating it with a string literal, to make it a meaningful paragraph." |
| 64 | + ] |
| 65 | + }, |
| 66 | + { |
| 67 | + "cell_type": "markdown", |
| 68 | + "metadata": {}, |
| 69 | + "source": [ |
| 70 | + "6. Solve this problem. Try to solve with the least number of statements as possible.\n", |
| 71 | + " 1. Create a variable x and assign 25 to it.\n", |
| 72 | + " 2. Create a variable y and assign 2.55 to it.\n", |
| 73 | + " 3. Create a variable z and assign the sum of x and y to it.\n", |
| 74 | + " 4. Print the result." |
| 75 | + ] |
| 76 | + }, |
| 77 | + { |
| 78 | + "cell_type": "markdown", |
| 79 | + "metadata": {}, |
| 80 | + "source": [ |
| 81 | + "7. This code has bugs in it. Fix this code.\n", |
| 82 | + "\n", |
| 83 | + " `2my-first_name = \"Ram\"`<br>\n", |
| 84 | + " `&my-age-is = 20`" |
| 85 | + ] |
| 86 | + } |
| 87 | + ], |
| 88 | + "metadata": { |
| 89 | + "kernelspec": { |
| 90 | + "display_name": "Python 3", |
| 91 | + "language": "python", |
| 92 | + "name": "python3" |
| 93 | + }, |
| 94 | + "language_info": { |
| 95 | + "codemirror_mode": { |
| 96 | + "name": "ipython", |
| 97 | + "version": 3 |
| 98 | + }, |
| 99 | + "file_extension": ".py", |
| 100 | + "mimetype": "text/x-python", |
| 101 | + "name": "python", |
| 102 | + "nbconvert_exporter": "python", |
| 103 | + "pygments_lexer": "ipython3", |
| 104 | + "version": "3.7.0" |
| 105 | + }, |
| 106 | + "pycharm": { |
| 107 | + "stem_cell": { |
| 108 | + "cell_type": "raw", |
| 109 | + "metadata": { |
| 110 | + "collapsed": false |
| 111 | + }, |
| 112 | + "source": [ |
| 113 | + "import datetime\n", |
| 114 | + "now = datetime.datetime.now()\n", |
| 115 | + "print (\"Current date and time : \")\n", |
| 116 | + "print (now.strftime(\"%Y-%m-%d %H:%M:%S\"))#%%\n" |
| 117 | + ] |
| 118 | + } |
| 119 | + } |
| 120 | + }, |
| 121 | + "nbformat": 4, |
| 122 | + "nbformat_minor": 1 |
| 123 | +} |
0 commit comments