{"id":30804353,"url":"https://github.com/chanakyavasantha/learnpython","last_synced_at":"2025-09-06T00:00:00.665Z","repository":{"id":180636917,"uuid":"665447653","full_name":"chanakyavasantha/LearnPython","owner":"chanakyavasantha","description":"Learning Resources for python","archived":false,"fork":false,"pushed_at":"2023-11-30T10:40:39.000Z","size":5900,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-11-30T11:29:26.909Z","etag":null,"topics":["learn-python","learning-by-doing","python","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chanakyavasantha.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-12T08:18:38.000Z","updated_at":"2023-11-30T10:40:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"c849c9e5-9a47-4368-921b-92c76b1c7f93","html_url":"https://github.com/chanakyavasantha/LearnPython","commit_stats":null,"previous_names":["chanakyavasantha/learnpython"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/chanakyavasantha/LearnPython","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanakyavasantha%2FLearnPython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanakyavasantha%2FLearnPython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanakyavasantha%2FLearnPython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanakyavasantha%2FLearnPython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanakyavasantha","download_url":"https://codeload.github.com/chanakyavasantha/LearnPython/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanakyavasantha%2FLearnPython/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273838353,"owners_count":25177162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["learn-python","learning-by-doing","python","unit-testing"],"created_at":"2025-09-05T23:59:59.348Z","updated_at":"2025-09-06T00:00:00.657Z","avatar_url":"https://github.com/chanakyavasantha.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PYTHON BASICS:\n\u003chr\u003e\n\n## **range function in python**:\n![Screenshot from 2023-08-02 21-01-07](https://github.com/chanakyavasantha/LearnPython/assets/93817654/157b3a8d-3088-43aa-b578-c6722eeba6e6)\n\n![Screenshot from 2023-07-13 14-18-38](https://github.com/chanakyavasantha/LearnPython/assets/93817654/24bc738d-07b0-4bb8-a57a-ae8c4949bdd8)# Learn Python \n# Questions on loops in python:\n- counting Number of Digits in a given number\n![Screenshot from 2023-07-12 14-02-38](https://github.com/chanakyavasantha/LearnPython/assets/93817654/60fad804-a55e-4ccc-9430-901e9e77e3ab)\n![Screenshot from 2023-07-12 14-04-04](https://github.com/chanakyavasantha/LearnPython/assets/93817654/e176ccd1-df98-4363-8805-065f1cff296b)\n\n- Sum of First n even numbers\n![Screenshot from 2023-07-12 14-19-59](https://github.com/chanakyavasantha/LearnPython/assets/93817654/12508463-4472-4938-b4a3-751e3a3cb832)\n![Screenshot from 2023-07-12 14-21-27](https://github.com/chanakyavasantha/LearnPython/assets/93817654/4939f010-1323-4139-9c28-d44179ecfe34)\n\n- Algorithm for checking whether a given is a prime or not:\n![Screenshot from 2023-07-13 14-10-27](https://github.com/chanakyavasantha/LearnPython/assets/93817654/fa943176-c733-4106-a3f9-a9678427fe6f)\n![Screenshot from 2023-07-13 14-11-19](https://github.com/chanakyavasantha/LearnPython/assets/93817654/520c8aa3-24e5-405f-b4da-28eb66e215f1)\n\n#### Questions on loops in python:\n  - Find Sum of first **n** natural numbers in python\n  - Optimized Approach\n  ![Screenshot from 2023-07-16 17-09-40](https://github.com/chanakyavasantha/LearnPython/assets/93817654/fba0a3ee-8f29-4d23-bad7-ebe6b21c4a79)\n  - Better Alogorithms could solve problems in a optimized approach\n\n#### Functions in python:\n![Screenshot from 2023-07-13 14-16-00](https://github.com/chanakyavasantha/LearnPython/assets/93817654/57f0fed5-b2e6-4e87-be51-83fd11a9cdd9)\nFunction should be defined so that:\n- it accepts input\n- it gives some ouput\n- The input have some specific data type\n- The produced will also have some specific data type\n![Uploading Screenshot from 2023-07-13 14-18-38.png\n- Similiarly we have input data type and out put data type for a function in python\n- The output data type is called return type\n#### Examples:\n- What is the return type for input()?\n  - String is the return type of input() function \n  - ![Screenshot from 2023-07-13 14-21-22](https://github.com/chanakyavasantha/LearnPython/assets/93817654/71517e06-2c4c-4546-9136-0a8fdbdd6fb8)\n  - ![Screenshot from 2023-07-13 14-26-42](https://github.com/chanakyavasantha/LearnPython/assets/93817654/7ce3d51c-cbfc-4c26-98b8-fda0c1738161)\n- Write a function in python that tells whether a given numbers is an even number:\n- ![Screenshot from 2023-07-16 17-38-43](https://github.com/chanakyavasantha/LearnPython/assets/93817654/75105a66-2635-4204-952b-c4e75ade3ec0)\n- ![Screenshot from 2023-07-16 17-38-06](https://github.com/chanakyavasantha/LearnPython/assets/93817654/35a382e4-a53d-4d57-9189-b0321932bf54)\n\n#### Exercise on Functions:\n- Write a fucntion to check , whether a given number is prime.\n    - Use both Brute Force Approach, and Optimized Approach\n```\n## Python Program to check whether a given number is prime using Brute Force Approach\nn = int(input()) # taking input from user\nflag = 0\nfor i in range(2,n):\n  if n % i == 0:\n    flag = 1\n    break\nif flag == 1:\n  print(\"The given number is not prime\")\nelse:\n  print(\"The gven number is prime\")\n\n```\n```\n## Python Program to check whether a given number is prime using Optimized Approach\nimport math\nn = int(input()) # taking input from user\nflag = 0\nfor i in range(2,int(math.sqrt(n))+1):\n  if n % i == 0:\n    flag = 1\n    break\nif flag == 1:\n  print(\"The given number is not prime\")\nelse:\n  print(\"The gven number is prime\")\n\n```\n- Write a function that takes two integers as parameters and returns their sum.\n```\n## Python Program to design a function that returns sum\ndef SUM(a,b):\n  return a+b\na = int(input(\"Enter a: \"))\nb = int(input(\"Enter b: \"))\nc = SUM(a,b)\nprint(c)\n```\n- Write a function that takes a list of numbers as input and returns the largest number in the list.\n```\n## Python Program to design a function that finds maximum in a list\ndef FindMax(li):\n  Max = li[0]\n  for i in range(len(li)):\n    if li[i] \u003e Max:\n      Max = li[i]\n  return Max\nli = list(map(int,input().split()))\nc = FindMax(li)\nprint(c)\n```\n- **ONE LINE CODE**\n```\nli = list(map(int,input().split()))\nc = max(li)\nprint(c)\n```\n- Implement a function that reverses a given string.\n![Screenshot from 2023-08-02 21-37-54](https://github.com/chanakyavasantha/LearnPython/assets/93817654/9dce7697-cb93-45c6-b364-ea5e559b91cc)\n```\ndef rev(a):\n  b = \"\"\n  for i in range(len(a)-1,-1,-1):\n    b += a[i]\n  return b # b will have reversed string\na = \"chanakya\"\nprint(rev(a))\n```\n```\na = \"kushik\"\nb = a[::-1]\nprint(b)\n```\n- Implement a function that takes a list of words and returns a new list with the words sorted in alphabetical order.\n```\ndef SortedList(li):\n  li.sort()\n  return li\nli = input().split()\nLi = SortedList(li)\nprint(Li)\n```\n**split Function in python**\u003cbr\u003e\n**li = list(map(int,input().split()))** How does this work?\n- Some Examples on split() function in python\n![Screenshot from 2023-08-03 21-15-20](https://github.com/chanakyavasantha/LearnPython/assets/93817654/bf4e84b3-83d1-45e1-8ef1-35c08c2454a6)\n- input() returns a string by default\n- split() returns a list, it's argumnent is the seperator , default seperator is space\n- input().split() returns a list of string seperated at space\n- map type casts a list with given data type. and returns a map object.\n- map object could be converted into list by list(map(....\n- list(map(int,input().split())) returns a list of integers by mapping strings to their corresponding integer values.\n```\nli = list(map(int,['2','3','4']))\nprint(li)\n```\n![Screenshot from 2023-08-03 21-21-02](https://github.com/chanakyavasantha/LearnPython/assets/93817654/05830a58-34d1-4a45-a257-19e718191804)\n\n\n- Write a function that removes duplicates from a list\n![Screenshot from 2023-08-03 21-44-04](https://github.com/chanakyavasantha/LearnPython/assets/93817654/ddf2f2a7-c69c-4fb1-9bd3-4dfdfac82cf0)\n\n\n- How Does jupyter notebook Work, How does it stores local variables data, how data is overriden?\n  \n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanakyavasantha%2Flearnpython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanakyavasantha%2Flearnpython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanakyavasantha%2Flearnpython/lists"}