{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyPD28qjNvtSkbd8iNRJ3qAF"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"id":"l7zTOmqZki_I","executionInfo":{"status":"ok","timestamp":1717677844804,"user_tz":-330,"elapsed":10,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}}},"outputs":[],"source":["#Example 2: Write a program which takes number input from the user and display all the prime numbers from 1 to number input given by user."]},{"cell_type":"code","source":["# Program to display all the prime numbers from 1 to number given by user\n","\n","# taking input from the uses\n","num = int(input(\"Enter a upper range: \"))\n","\n","print(\"Prime numbers between 1 and\", num, \"are:\")\n","\n","for x in range(1, num + 1):\n","   # all prime numbers are greater than 1\n","   if x >1:\n","       for i in range(2, x):\n","           if (x % i) == 0:\n","               break\n","       else:\n","           print(x)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"hLnaNgbLkl__","executionInfo":{"status":"ok","timestamp":1717677853899,"user_tz":-330,"elapsed":9098,"user":{"displayName":"Amit Sachan","userId":"17076119069500437280"}},"outputId":"bde38e03-b064-4c89-c924-1bc37a3dd0ad"},"execution_count":2,"outputs":[{"output_type":"stream","name":"stdout","text":["Enter a upper range: 50\n","Prime numbers between 1 and 50 are:\n","2\n","3\n","5\n","7\n","11\n","13\n","17\n","19\n","23\n","29\n","31\n","37\n","41\n","43\n","47\n"]}]}]}