[
  {
    "path": "CONTRIBUTING.md",
    "content": "# What You Waiting For Fork it!\nFeel free to fork the repository and make changes!\nIf you feel there is need to change something pull request!\nI'll check and review the changed program if it adds any value to the repo i'll definitely merge it!\n"
  },
  {
    "path": "Display ASCII Value of a Character.py",
    "content": "# ASCII Value of Character \n\n# Simply ender a character from the keyboard\nuser_input = input('Give me a character: ')\n\n# Print the ASCII value of assigned character  \nprint(\"The ASCII value of '\" + user_input + \"' is\", ord(user_input)) \n"
  },
  {
    "path": "Double the number pattern",
    "content": "rows = 9\nfor i in range(1, rows):\n    for j in range(-1+i, -1, -1):\n        print(format(2**j, \"4d\"), end=' ')\n    print(\"\")\n"
  },
  {
    "path": "Drawing_With_Turtle.py",
    "content": "#This is a example for turtle\r\n#This shows how to draw a star\r\n#For more tutorials visit https://www.tutorialspoint.com/turtle-programming-in-python\r\n\r\n# import turtle library\r\nimport turtle             \r\nmy_pen = turtle.Turtle()      \r\nfor i in range(50):\r\n   my_pen.forward(50)           \r\n   my_pen.right(144)               \r\nturtle.done()"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "Medium level python program",
    "content": "rows = 6\nfor row in range(1, rows):\n    for column in range(row, 0, -1):\n        print(column, end=' ')\n    print(\"\")\n"
  },
  {
    "path": "Pattern Program",
    "content": "rows = 6\nfor num in range(rows):\n    for i in range(num):\n        print(num, end=\" \")  # print number\n    print(\" \")\n"
  },
  {
    "path": "Pattern Python Program",
    "content": "rows = 5\nfor i in range(rows, 0, -1):\n    num = i\n    for j in range(0, i):\n        print(num, end=' ')\n    print(\"\\r\")\n"
  },
  {
    "path": "README.md",
    "content": "# Beginners-Python-Programs\n<strong>[18 Nov 2025] Final Update: </strong>This was my first Repo and I created it when I was fairly young and completely new to computer programming. I no longer have time to update/maintain it in anyway.<br>Thus, starting today, <strong>This Repository will be available as a Public Archive only.</strong><br/><br/>\n\nBasic python CLI programs as examples.<br>\nAll the examples are useful examples.<br>\nThese examples are of beginner level.<br>\n\nNote: In 2.x versions input isn't useful. Similarly, in 3.x versions raw_input isn't useful. Also, xrange() and other methods are discontinued or changed in 3.x versions of Python. Change the keywords accordingly.\n\n<br>\nUpdate: I wrote these programs when I was just starting out with programming, now I realize that many of them seem quite amateur in their rendering so I've decided to audit through all of them and update them according to my current capabilities.\n<br>\n<br>\nFiles outside particular directories have not been checked yet <br>\nFiles inside, directories offer better code and explanation\n<br>\n<br>\nAlso see this : Beginners-Python-Examples/CONTRIBUTING.md<br>\n"
  },
  {
    "path": "Turtle_Drawing.py",
    "content": "import turtle \r\n\r\nninja = turtle.Turtle()\r\n\r\nninja.speed(10)\r\n\r\nfor i in range(180):\r\n    ninja.forward(100)\r\n    ninja.right(30)\r\n    ninja.forward(20)\r\n    ninja.left(60)\r\n    ninja.forward(50)\r\n    ninja.right(30)\r\n    \r\n    ninja.penup()\r\n    ninja.setposition(0, 0)\r\n    ninja.pendown()\r\n    \r\n    ninja.right(2)\r\n    \r\nturtle.done()"
  },
  {
    "path": "_config.yml",
    "content": "theme: jekyll-theme-minimal"
  },
  {
    "path": "algorithms/README.md",
    "content": "\n<pre>\n<i>'algorithms'</i> Sub-directory contains all <strong>algorithms</strong>\nfurther separated in different particular sub directories\n</pre>\nThe programs have been <strong>re-checked</strong> and <strong>re-mastered</strong> by me! <br/>\nAlthough i've tried to keep it as orignal as possible. <br/>\nKeep Patience It'll take time to go through every program!! <br/>\n<strong>Thanks</strong>\n"
  },
  {
    "path": "algorithms/analysis/README.md",
    "content": "\n\n\n<pre>\n<i>'analysis'</i> Sub-directory contains all \n<strong>analysis related algorithms</strong>.\n\n<strong>Thanks</strong>\n</pre>\n"
  },
  {
    "path": "algorithms/analysis/bigo_notation.py",
    "content": "from math import log\nimport numpy as np\nimport matplotlib.pyplot as plt\n%matplotlib inline\nplt.style.use('bmh')\n\n# Set up runtime comparisons\n\nn = np.linspace(1,10,1000)\nlabels = ['Constant','Logarithmic','Linear','Log Linear','Quadratic','Cubic','Exponential']\nbig_o = [np.ones(n.shape),np.log(n),n,n*np.log(n),n**2,n**3,2**n]\n\n# Plot setup\n\nplt.figure(figsize=(12,10))\nplt.ylim(0,50)\n\nfor i in range(len(big_o)):\n    plt.plot(n,big_o[i],label = labels[i])\n\n\nplt.legend(loc=0)\nplt.ylabel('Relative Runtime')\nplt.xlabel('n')\n"
  },
  {
    "path": "algorithms/analysis/count.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n# Simple algorithm to count\r\n# number of occurrences of (n) in (ar)\r\n\r\n# Sudo: Algorithm\r\n# \teach time (n) is found in (ar)\r\n# \t(count) varible in incremented (by 1)\r\n\r\n# I've put spaces to separate different \r\n# stages of algorithms for easy understanding\r\n# however isn't a good practise\r\n\r\ndef count(ar, n):\r\n\tcount = 0\r\n\t\r\n\tfor element in ar:\r\n\t\t# More complex condition could be \r\n\t\t# => (not element != n)\r\n\t\tif element == n:\r\n\t\t\tcount += 1\r\n\t\r\n\treturn count\r\n\r\n# Testing\r\n# add your test cases in list below\r\ntest_cases = [([1, 1, 2, 3, 5, 8, 13, 21, 1], 1), (\"Captain America\", \"a\")]\r\nfor test_case in test_cases:\r\n\tprint(\"TestCase: {}, {}\".format(test_case[0], test_case[1]))\r\n\tprint(\"Results: {}\\n\".format(count(test_case[0], test_case[1])))\r\n\r\n# You can add condition to check weather output is correct\r\n# or not\r\n"
  },
  {
    "path": "algorithms/analysis/enum.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Enum function\n# yields a tuple of element and it's index\ndef enum(ar):\n\tfor index in range(len(ar)):\n\t\tyield((index, ar[index]))\n\n# Test\ncase_1 = [19, 17, 20, 23, 27, 15]\nfor tup in list(enum(case_1)):\n\tprint(tup)\n\n\n# Enum function is a generator does not \n# return any value, instead generates\n# tuple as it encounters element of array\n\n# Tuples can be appended to list\n# and can be returned after iteration\n# However,\n# Generator is a good option\n"
  },
  {
    "path": "algorithms/analysis/length.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport math\n\n# Length of array(number of elements in array)\n# is simple algorithm\n#  Iterates through array\n#  at each iteration (count) variable\n#  is incremented\n# \n# This solution is ideal for small array\n# But not that good for bigger array's\n\n# There are many ways to do same thing\n# but always go with solution that is\n# simple, and has least instructions\n# for computer to execute, making\n# process faster\n\n# is_ap parameter indicates weather array\n# is an arithmetic progression or not\n#\n# Similarly, \n# is_gp indicates weather array is an geometric progression or not\n# If array is either ap or gp then it's length can be\n# found by derivation of it's general term formula\n# e.g. ap's general term,\n# tn = a + (n - 1)d\n# thus, n = (tn - a) / d + 1 \n\ndef length(ar, is_ap = False, is_gp = False, big_data = False, data_outline = []):\n\t# Length of data if it is an arithmetic progression\n\t# using derived formula, n = (tn - a) / d + 1\n\tif is_ap:\n\t\treturn ((ar[-1] - ar[0]) / (ar[1] - ar[0])) + 1\n\n\t# Length of data if it is an geometric progression\n\t# using derived formula, n = ((log base 10 an / a1) / log 10 r) + 1\n\telif is_gp:\n\t\t# length is never a float\n\t\treturn int(math.log10((ar[-1] / ar[0])) / math.log10((ar[1] / ar[0])) + 1)\n\n\t# Length of big data using data outline\n\t# data outline is selective elements to be counted from entire\n\t# data\n\telif big_data:\n\t\tcount = 0\n\t\tfor element in data_outline:\n\t\t\tcount += ar.count(element)\n\t\treturn count \n\t\n\t# Sequential counting\n\t# of elements in array\n\telse:\n\t\tres = 0\n\t\tfor item in ar:\n\t\t\tres += 1\n\t\treturn res \n\t\t\n\n# Test\n# Geometric progression Test\nif length([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096], None, is_gp = True) == 13:\n\tprint(\"\\nLength of geometric progression: \" + str(13))\n\tprint(\"--> geometric progression counting works!\\n\")\nelse:\n\tprint(\"Something's wrong with gp feature\")\n\n# Arithmetic progression test\nif length([1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43], is_ap = True) == 15:\n\tprint(\"Length of arithmetic progression: \" + str(15))\n\tprint(\"--> arithmetic progression counting works!\\n\")\nelse:\n\tprint(\"Something's wrong with ap feature\")\n\n# Big data test\n# Passing only useful numbers in outline array\nif length([1, 1, 4, 5, 7, 1, 9, 5, 2, 4, 3, 5, 9], None, None, True, [1, 4, 5, 7, 9]) == 11:\n\tprint(\"Length of arithmetic progression: \" + str(11))\n\tprint(\"--> big data counting works!\\n\")\nelse:\n\tprint(\"Something's wrong with ap feature\")\n\n# Small data\nprint(\"Length: \" + str(length([1, 1, 2, 3, 5, 8, 13, 21, 34, 55])))\nprint(\"Everything Works!\\n\")\n"
  },
  {
    "path": "algorithms/analysis/max.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Finds the maximum number\n# in un-sorted data\n\n# Sudo Algo:\n# Iterate through data\n# each time a number(say k) greater than, previous \n# consideration(say p) is found, replace previous \n# consideration(p) with that greater number(k)\n# By this way, \n# \tAt last we get the maximum number from data\n\ndef max_(seq):\n\tmax_n = seq[0]\n\tfor item in seq[1:]:\n\t\tif item > max_n:\n\t\t\tmax_n = item \n\treturn max_n\n\n\n# Test\n# Add your tests too!\ntests = [[9017289, 782367, 736812903, 9367821, 71256716278, 676215, 2398, 0, 1], \n\t\t [19208, 9239, 4376, 738, 78, 51, 5, 6, 12, 78, 123, 65765, 1999999999],\n\t\t [1, 2, 4, 7, 9]]\n\n# checking our functions results\n# with python's built-in max() function\nfor test_i in range(len(tests)):\n\tm = max_(tests[test_i])\n\tif m == max(tests[test_i]):\n\t\tprint(\"Max number in array({}) -> \".format(test_i + 1) + str(m))\n\telse:\n\t\tprint(\"Oops! Someting went wrong!\") \n"
  },
  {
    "path": "algorithms/analysis/mean.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# f(x) = s(x) / l(x) ______(e1)\n# Functions below same principle as (e1)\n#\n# Here,\n# Mean value can be float\n# 'er is need to declare float values\n\n# Function to get mean of given args\ndef mean_(*args):\n\tsum_ = 0.0\n\tlength_ = 0.0\n\n\tfor arg in args:\n\t\tsum_ += arg\n\t\tlength_ += 1.0\n\n\treturn sum_ / length_\n\n# Function to get mean of array\ndef mean_ar(ar):\n\treturn float(sum(ar))/float(len(ar))\n\n# Another feature can be start index\n# and end index of array\n\n# Test\n# First function\nif mean_(12, 445, 76, 23, 7, 9, 17, 19, 100) == 78.66666666666667:\n\tprint(\"First Function Works!\")\n\n# Second function\nif mean_ar([12, 445, 76, 23, 7, 9, 17, 19, 10]) == 68.66666666666667:\n\tprint(\"Second Function Works!\")\n\n"
  },
  {
    "path": "algorithms/analysis/median.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Median\n# Median is the middle value of data\n# Data of odd length has a mid value\n# but, data of even length has 2 mid values\n# so their median is mean of these 2 values\n\n# ranked parameter is to tell function \n# weather data is ranked(sorted) or not\n# \ndef median(ar, ranked = False):\n\tif not ranked:\n\t\tdata = sorted(ar[:])\n\telse:\n\t\t# Don't need an else block still\n\t\t# but to map program properly\n\t\t# i've added it \n\t\tdata = ar[:]\n\n\t# Data with odd length\n\tif len(data) % 2 != 0:\n\n\t\t# f(x) = (l(x) + 1) / 2 th term is the median of data\n\t\t# but since computer starts counting from 0\n\t\t# and not from 1, there is no need to add 1 \n\t\t# to length of data, otherwise results are\n\t\t# not accurate\n\t\treturn data[len(data) / 2]\n\n\t# Data with even length\n\t# f(x) = [l(x) / 2 th term + (l(x) + 2) / 2th term] / 2\n\t# 2.0 is to declare that median can be a float\n\t# in case of even length data\n\treturn (data[len(data) / 2 - 1] + data[(len(data) + 1) / 2]) / 2.0\n\n# Test\nodd = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627]\neven = [8, 7, 5, 2, 1, 3, 4, 6]\n\nif median(odd, ranked = True) == 131415 and median(even) == 4.5:\n\t\n\t# Print statements on separate lines look better\n\tprint(\"Median of odd data: \" + str(131415))\n\tprint(\"Median of even data: \" + str(4.5))\n\tprint(\"Yeah, it works!\")\n\nelse:\n\t# If algo didn't work\n\tprint(\"There's something wrong!\")\n\n# This median is for un-distributed/un-grouped data\n# i.e. no frequencies\n# plain numbers in an array\n"
  },
  {
    "path": "algorithms/analysis/min.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\n# Finds the minium number\n# in un-sorted data\n\n# Sudo Algo:\n# Iterate through data\n# each time a number(say k) is less than previous \n# consideration(say p), replace previous \n# consideration(p) with that smaller number(k)\n# By this way, \n# \tAt last we get the smallest(minium) number from data\n\ndef min_(seq):\n\tmin_n = seq[0]\n\tfor item in seq[1:]:\n\t\tif item < min_n:\n\t\t\tmin_n = item \n\treturn min_n\n\n\n# Test\n# Add your tests too!\ntests = [[9017289, 782367, 736812903, 9367821, 71256716278, 676215, 2398, 0, 1], \n\t\t [19208, 9239, 4376, 738, 78, 51, 5, 6, 12, 78, 123, 65765, 1999999999],\n\t\t [1, 2, 4, 7, 9]]\n\n# checking our functions results\n# with python's built-in min() function\nfor test_i in range(len(tests)):\n\tm = min_(tests[test_i])\n\tif m == min(tests[test_i]):\n\t\tprint(\"Min number in array({}) -> \".format(test_i + 1) + str(m))\n\telse:\n\t\tprint(\"Oops! Someting went wrong!\") \n"
  },
  {
    "path": "algorithms/analysis/mode.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\n# Mode\n# mode or modal value, is the number in data\n# that has highest frequency, or occurs in data/array\n# maximum number of times\n\n# This function produces an outline of data\n# each element occurs only once in outline\n# that means no repeats of same numbers\ndef reduce_data(data):\n\t# Simplest way to do this, just 1 line of code:\n\t# return list(set(data))\n\t# since set data structure does not have repeats\n\n\t# But below code is much more\n\t# illustrative and easier to understand\n\n\tdata_outline = []\n\tfor item in data:\n\t\tif item not in data_outline:\n\t\t\tdata_outline.append(item)\n\n\treturn data_outline\n\n# To find mode, we apply same principle, that works\n# behind finding the maximum or minimum number(see max.py, min.py)\ndef mode(data):\n\tmode_ = data[0]\n\tmax_frequency = data.count(data[0])\n\n\t# Insted of iterating through every repeat of \n\t# same number, then counting multiple repeats\n\t# of number multiple times, iterating through outline\n\t# of data is convinient, less time consuming.\n\tfor value in reduce_data(data[1:]):\n\t\tif data.count(value) > max_frequency:\n\t\t\tmode_ = value \n\t\t\tmax_frequency = data.count(value)\n\n\t# instead of just mode, it's freq \n\t# can also be helpful\n\treturn (mode_, max_frequency)\n\n# Test\n# Add your test cases\ntests = [\n\t[19, 17, 25, 34, 57, 17, 25, 52, 47, 42, 25, 17, 3, 0, 3, 41, 17],\n\t[1917, 2534, 5717, 1725, 5247, 1917, 4117, 5717, 17303, 1917],\n]\n\n# Function does work, \n# Check yourself\nfor test in tests:\n\tmodal_v = mode(test)\n\tprint(\"\\nData outline: {}\".format(reduce_data(test)))\n\tprint(\"Mode: {}\\nFrequency: {}\".format(modal_v[0], modal_v[1]))\n\nprint(\"\")\n\n# Mode for un-grouped data\n"
  },
  {
    "path": "algorithms/analysis/sort.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Bubble Sort\n# Ideal sorting algorithm for \n# small data/array\n\n# temporary parameter tells\n# function to sort a copy of \n# orignal array, and not the array itself\n\n# reverse parameter tells func\n# to sort array in reverse/decending\n# order\n\ndef sort_(arr, temporary = False, reverse = False):\n\t\n\t# Making copy of array if temporary is true\n\tif temporary:\n\t\tar = arr[:]\n\telse:\n\t\tar = arr\n\t\n\t# To blend every element\n\t# in correct position\n\t# length of total array is required\n\tlength = len(ar)\n\t\n\t# After each iteration right-most\n\t# element is completed sorted\n\twhile length > 0:\n\n\t\t# So every next time we iterate only\n\t\t# through un-sorted elements\n\t\tfor i in range(0, length - 1):\n\n\t\t\tif reverse:\n\n\t\t\t\t# Swapping greater elements to left\n\t\t\t\t# and smaller to right\n\t\t\t\t# decending order\n\t\t\t\tif ar[i] < ar[i+1]:\n\t\t\t\t\ttmp = ar[i]\n\t\t\t\t\tar[i] = ar[i + 1]\n\t\t\t\t\tar[i + 1] = tmp\n\t\t\telse:\n\n\t\t\t\t# Swapping greater elements to right\n\t\t\t\t# and smaller to left\n\t\t\t\t# accending order\n\t\t\t\tif ar[i] > ar[i+1]:\n\t\t\t\t\ttmp = ar[i]\n\t\t\t\t\tar[i] = ar[i + 1]\n\t\t\t\t\tar[i + 1] = tmp\n\n\n\t\t# making sure loop breaks\n\t\tlength = length - 1 \n\t\n\t# if temporary, then returning\n\t# copied arr's sorted form\n\t# cuz if not returned, then function\n\t# is literally of no use\n\tif temporary:\n\t\treturn ar \t\n\n# See proper explaination \n# at: https://www.geeksforgeeks.org/bubble-sort/\n# a good site!\n\n\n# Testing\ntests = [[7, 8, 9, 6, 4, 5, 3, 2, 1, 15], [1, 90, 1110, 1312, 1110, 98, 76, 54, 32, 10], ] # Add your test cases \n\nfor test in tests:\n\taccend, decend = sort_(test, True), sort_(test, True, True)\n\tif accend == sorted(test) and decend == sorted(test, reverse = True):\n\t\tprint(\"Orignal: {}\".format(test))\n\t\tprint(\"Sorted: {}\".format(accend))\n\t\tprint(\"Sorted(reverse): {}\\n\".format(decend))\n\telse:\n\t\tprint(\"Something went wrong!\\n\")\n\n\n# Seems our bubble sort works\n# however for small data/array!\n"
  },
  {
    "path": "algorithms/analysis/sum.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Sudo ALgorithm:\n# both functions work on same principle\n# Iterate through array/arguments\n# add each element to variable(res)\n# return sum\n\ndef sum_(*args):\n\tres = 0.0\n\tfor arg in args:\n\t\tres += arg\n\treturn res\n\ndef sum_ar(ar, end_i):\n\t# end_i is the last index of array\n\t# till which function should add\n\t# array's elements\n\tif end_i > 0 and end_i <= len(ar):\n\t\tif end_i == len(ar):\n\t\t\tend_i = end_i - 1\n\telse:\n\t\tend_i = len(ar) - 1\n\n\tres = 0.0\n\tfor elem in ar[:end_i + 1]:\n\t\tres += elem \n\n\treturn res \n\n# Simple Algorithm\n\n# Testing\n# First Function\nif sum_(1, 2, 3, 4, 5, 6, 7, 8, 9) == 45:\n\tprint(\"First Function Works!\")\n\n# Second Function\nif sum_ar([1, 2, 3, 4, 5, 6, 7, 8, 9], -1) == 45:\n\tprint(\"Second Function Partially Works!\")\n\nif sum_ar([1, 2, 3, 4, 5, 6, 7, 8, 9], 6) == 28:\n\tprint(\"Second Function Completely Works!\")\n"
  },
  {
    "path": "algorithms/analysis/useful_function_mapping.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\ndef squared(n):\n\treturn n * n \n\ndef cubed(n):\n\treturn n * n * n \n\ndef raise_power(n, power):\n\tfor t in range(power):\n\t\tn *= n \n\treturn n \n\ndef is_divisible(n, t):\n\treturn n % t == 0\n\ndef is_even(n):\n\treturn n % 2 == 0\n\ndef is_odd(n):\n\treturn n % 2 != 0\n\n# These all functions are extremely \n# helpful when used with map method of python\n# map(func, list) basically applies given function \n# to every element of list and appends results to a new\n# list\n\n# e.g.\nprint(map(squared, [1, 3, 5, 7, 9, 11, 13, 15]))\n\n# for functions with multiple args\n# see: https://www.quora.com/How-do-I-put-multiple-arguments-into-a-map-function-in-Python\n\n"
  },
  {
    "path": "algorithms/numbers/README.md",
    "content": "\n\n\n\n<pre>\n<i>'numbers'</i> Sub-directory contains all \n<strong>numbers/math/sequences(arrays) related algorithms</strong>.\n\n<strong>Thanks</strong>\n</pre>\n"
  },
  {
    "path": "algorithms/numbers/binary_to_decimal_converter.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\nimport sys\n\n# Binary to decimal conversion\n# See explaination: https://i.imgur.com/heAT0PB.gif   , \n# https://www.electronics-tutorials.ws/binary/bin_2.html\n\n# Pesudo code:\n# Iterate through binary num\n# if 0 then pass\n# else result = result + bit(1) * 2 ** index of bit(1)\n\ndef binary_to_decimal_conv(binary_string):\n\tres = 0\n\tbinary_l = list(binary_string)\n\tfor bit_i in range(len(binary_l)):\n\t\tres += int(binary_l[bit_i]) * (2 ** bit_i) \n\treturn res \n\n# Test\n# Testing interface\ni = 0\nwhile True:\n\tif raw_input(\"\\n[{}] Exit(press e) or Continue(press c): \".format(i)).strip().lower() == \"c\":\n\t\tprint(\"Decimal form: \" + str(binary_to_decimal_conv(raw_input(\"\\nBinary?: \"))))\n\telse:\n\t\tprint(\"\\nHope you enjoyed!\")\n\t\tsys.exit()\n\ti += 1\n"
  },
  {
    "path": "algorithms/numbers/collatz_sequence.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport sys\n\n# Collatz conjecture\n# is a series of numbers\n# where the orignal number is manipulated, until\n# one is obtained\n# if n is even n // 2 is the next number\n# else n * 3 \n# No matter what the value of n we'll,\n# always reach 1.\n# See: https://en.wikipedia.org/wiki/Collatz_conjecture\n\n# Collatz series generator\ndef collatz_conjecture(n):\n    if n < 1: \n    \traise Exception(\"\\n  Expected a value greater than 1\")\n\t\n    while n != 1:\n\t\tif n % 2 == 0:\n\t\t\tn = n // 2\n\t\telse: n = 3*n + 1\n\t\tyield n\n\n# If n will be negative then\n# sequence will be infinite\n\n# Interface\n# Test/Play\ni = 0\nwhile True:\n\tif raw_input(\"\\n[%i] Continue[Y/n]?: \" % i).strip().lower() == \"y\":\n\t\tfor v in collatz_conjecture(int(raw_input(\"N?: \"))):\n\t\t\tprint(\"  > \" + str(v))\n\t\ti += 1\n\telse:\n\t\tprint(\"\\nSee you soon!\")\n\t\tsys.exit(0)\n\n"
  },
  {
    "path": "algorithms/numbers/compare_array_elements.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n# Compares elements at same \r\n# index in 2 different arrays\r\n# and so called generates tuple of \r\n# that value, index, array number\r\n# however if both numbers are equal\r\n# returns zero simply\r\n\r\n# Prime condition for correct results\r\n# length(arr1) == length(arr2)\r\n\r\ndef compare_array_elements(arr1, arr2):\r\n\tfor l in range(len(arr1)):\r\n\t\tif arr1[l] > arr2[l]:\r\n\t\t\tyield (arr1[l], l, 1)\r\n\t\telif arr1[l] < arr2[l]:\r\n\t\t\tyield (arr2[l], l, 2)\r\n\t\telse:\r\n\t\t\tyield(0)\r\n\r\n\r\n# Tests\r\ntests = [\r\n\t[\r\n\t\t[21, 3454, 12, 77, 21, 90, 235],\r\n\t\t[123, 54, 21, 7, 23, 987, 21312]\r\n\t],\r\n\r\n\t[\r\n\t\t[1223, 8273, 17732, 7127],\r\n\t\t[12989, 2131223, 129, 10]\r\n\t]\r\n]\r\n\r\n# Does not test last condition of function\r\nfor test in tests:\r\n\tfor n, index, array_n in compare_array_elements(test[0], test[1]):\r\n\t\tprint(\"  [ %i ] is biggest value at index(%i) from array(%i)\" %(n, index, array_n))\r\n"
  },
  {
    "path": "algorithms/numbers/factorial.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Factorial\n# is a mathematical function which \n# determines number of all possibilities\n# you can arrange 'n' number of objects!\n#\n# If there are 5 options in total\n# At first: there are 5 to choose from\n# 5 X\n# then, after choosing 1 from those 5 we'd have\n# 4 remaining, 5 x 4 x\n# then 3 remaining, 5 x 4 x 3\n# then 2, 5 x 4 x 3 x 2\n# then 1, 5 x 4 x 3 x 2 x 1 = 120\n\n# n is total number of objects\ndef factorial(n):\n\tif n <= 1:\n\t\treturn 1\n\telse:\n\t\tn = n * factorial(n - 1)\n\t\treturn n\n\n# Recursion is the easiest way to \n# solve this problem\n# but, to make sure recursion's depth ends, above\n# condition is necessary, otherwise\n# errors occur\n\n# Another way to solve problem\ndef factorial_(n):\n\tif n <= 1:\n\t\treturn 1\n\telse:\n\t\tm = 1\n\t\t# range function produces inclusive range\n\t\tfor integer in range(1, n + 1):\n\t\t\tm *= integer\n\t\treturn m \n\n# This solution is bigger \n# and looks much more complex \n# than the recursion one\n# Both work the same however\n\n# Test\nif factorial(5) == factorial_(5) == 120:\n\tprint(\"(\" + str(5) + \")! == \" + str(120))\n\tprint(\"Both functions work!\\n-Try it yourself-\")\n\tx = int(raw_input(\"\\nNumber: \"))\n\tprint(\"(\" + str(x) + \")! == \" + str(factorial(x)))\nelse:\n\tprint(\"Someting went wrong!\")\n"
  },
  {
    "path": "algorithms/searching/binary_search.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\nimport sys\n\n# I'm too lazy to explain how it works, \n# instead check below sites out:\n# https://en.wikipedia.org/wiki/Binary_search_algorithm\n# https://www.geeksforgeeks.org/binary-search/\n\n# Make sure you know concept of Recursion\n\n# Function explaination:\n# ar is the array\n# f is starting index for divided search array\n# l is ending index for divided search array\n# v is the query to search in array data space\n# sorted_ar tells the func, if array is sorted or not\n# as binary search won't work on an un-sorted array\n\ndef binary_search(arr, f, l, v, sorted_ar = False):\n\t# need an ordered/sorted array for search, \n\t# else search won't produce desirable results\n\tif not sorted_ar:\n\t\tarr.sort()\n\t\n\t# If input is invalid\n\tif l - f < 0:\n\t\treturn -1\n\n\telse:\n\t\t# Index of mid-term of array[f:l+1]\n\t\tmid_element_i = (f + l) // 2\n\n\t\t# If mid-term matches the query\n\t\tif arr[mid_element_i] == v:\n\t\t\treturn mid_element_i\n\t\t\n\t\t# If query is bigger than that mid-term\n\t\t# then we'll look at next_half of array\n\t\telif v > arr[mid_element_i]:\n\t\t\treturn binary_search(arr, mid_element_i+1, l, v, True)\n\t\t\n\t\t# else query is smaller than mid-term \n\t\t# so we'll look at lesser half of array\n\t\telse:\n\t\t\treturn binary_search(arr, f, mid_element_i-1, v, True)\n\n# Tests\n# Add your tests\n# Arrays below are not sorted or are un-ordered\n# Index returned by function is for sorted array\n# thus index might differ for same element, array below and in sorted array!\ntests = [\n\t[10, 29, 38, 47, 56, 19, 28, 37, 46, 50],\n\t[1, 92, 83, 74, 65, 29, 84, 75],\n\t[1, 21, 32, 43, 54, 65, 79],\n\t[7, 7],\n]\n\n# Play as long as you can\n# Searches query in all of arrays in tests\ni = 0\nwhile True:\n\tif raw_input(\"\\n[%i] Exit(press e) or Continue(press c): \" % i) == \"e\":\n\t\tsys.exit()\n\tq = int(raw_input(\"\\nSearch?: \"))\n\tprint(\"Results:\")\n\tfor test in tests:\n\t\tfind_i = binary_search(test, 0, len(test) - 1, q, False)\t\n\t\tif test[find_i] == q:\n\t\t\tprint(\"  Found [{}] at index({}) in array({})\".format(q, find_i, tests.index(test) + 1))\n\t\telse:\n\t\t\t# else is executed means, \n\t\t\t# something is wrong with the algorithm\n\t\t\tprint(\"  No results for [{}] in array({}). Try another search!\".format(q, tests.index(test) + 1))\n\ti += 1\n"
  },
  {
    "path": "algorithms/sorting/README.md",
    "content": "\n\n\n<pre>\n<i>'sorting'</i> Sub-directory contains all \n<strong>sorting algorithms</strong>.\n\n<strong>Thanks</strong>\n</pre>\n"
  },
  {
    "path": "algorithms/sorting/bubble_sort.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Bubble Sort\n# Ideal sorting algorithm for \n# small data/array\n\n# temporary parameter tells\n# function to sort a copy of \n# orignal array, and not the array itself\n\n# reverse parameter tells func\n# to sort array in reverse/decending\n# order\n\ndef sort_(arr, temporary = False, reverse = False):\n\t\n\t# Making copy of array if temporary is true\n\tif temporary:\n\t\tar = arr[:]\n\telse:\n\t\tar = arr\n\t\n\t# To blend every element\n\t# in correct position\n\t# length of total array is required\n\tlength = len(ar)\n\t\n\t# After each iteration right-most\n\t# element is completed sorted\n\twhile length > 0:\n\n\t\t# So every next time we iterate only\n\t\t# through un-sorted elements\n\t\tfor i in range(0, length - 1):\n\n\t\t\tif reverse:\n\n\t\t\t\t# Swapping greater elements to left\n\t\t\t\t# and smaller to right\n\t\t\t\t# decending order\n\t\t\t\tif ar[i] < ar[i+1]:\n\t\t\t\t\ttmp = ar[i]\n\t\t\t\t\tar[i] = ar[i + 1]\n\t\t\t\t\tar[i + 1] = tmp\n\t\t\telse:\n\n\t\t\t\t# Swapping greater elements to right\n\t\t\t\t# and smaller to left\n\t\t\t\t# accending order\n\t\t\t\tif ar[i] > ar[i+1]:\n\t\t\t\t\ttmp = ar[i]\n\t\t\t\t\tar[i] = ar[i + 1]\n\t\t\t\t\tar[i + 1] = tmp\n\n\n\t\t# making sure loop breaks\n\t\tlength = length - 1 \n\t\n\t# if temporary, then returning\n\t# copied arr's sorted form\n\t# cuz if not returned, then function\n\t# is literally of no use\n\tif temporary:\n\t\treturn ar \t\n\n# See proper explaination \n# at: https://www.geeksforgeeks.org/bubble-sort/\n# a good site!\n#can add flag to reduce time complexity\n\n# Testing\ntests = [[7, 8, 9, 6, 4, 5, 3, 2, 1, 15], [1, 90, 1110, 1312, 1110, 98, 76, 54, 32, 10], ] # Add your test cases \n\nfor test in tests:\n\taccend, decend = sort_(test, True), sort_(test, True, True)\n\tif accend == sorted(test) and decend == sorted(test, reverse = True):\n\t\tprint(\"Orignal: {}\".format(test))\n\t\tprint(\"Sorted: {}\".format(accend))\n\t\tprint(\"Sorted(reverse): {}\\n\".format(decend))\n\telse:\n\t\tprint(\"Something went wrong!\\n\")\n\n\n# Seems our bubble sort works\n# however for small data/array!\n"
  },
  {
    "path": "algorithms/sorting/insertion_sort.py",
    "content": "# -*- coding: utf-8 -*-\n\n# Insertion Sort\n# Ideal sorting algorithm for \n# small/small-medium data/array\n\n# temporary parameter tells\n# function to sort a copy of \n# orignal array, and not the array itself\n\n# reverse parameter tells func\n# to sort array in reverse/decending\n# order\n\n\ndef sort_(arr,temporary=False,reverse=False):\n    \n    # Making copy of array if temporary is true\n    if temporary:\n        ar = arr[:]\n    else:\n        ar = arr\n    \n    # To blend every element\n\t# in correct position\n\t# length of total array is required\n    length = len(ar)\n    \n    # After each iteration left-most\n\t# sub-array is completed sorted\n    for i in range(1,length):\n        # In each iteration we place\n        # the current element to its\n        # proper position in left sorted \n        # sub array\n        tmp = ar[i]\n        j = i-1\n        if reverse:\n            while j>=0 and tmp>ar[j]:\n                ar[j+1]=ar[j]\n                j-=1\n            ar[j+1]=tmp\n        else:\n            while j>=0 and tmp<ar[j]:\n                ar[j+1]=ar[j]\n                j-=1\n            ar[j+1]=tmp\n\n\n    # if temporary, then returning\n\t# copied arr's sorted form\n\t# cuz if not returned, then function\n\t# is literally of no use\n    if temporary:\n        return ar\n\n\n# See proper explaination \n# at: https://www.hotdogcode.com/insertion-sort/\n\n\n# Testing\ntests = [[7, 8, 9, 6, 4, 5, 3, 2, 1, 15], [1, 90, 1110, 1312, 1110, 98, 76, 54, 32, 10], ] # Add your test cases \n\nfor test in tests:\n\taccend, decend = sort_(test, True), sort_(test, True, True)\n\tif accend == sorted(test) and decend == sorted(test, reverse = True):\n\t\tprint(\"Orignal: {}\".format(test))\n\t\tprint(\"Sorted: {}\".format(accend))\n\t\tprint(\"Sorted(reverse): {}\\n\".format(decend))\n\telse:\n\t\tprint(\"Something went wrong!\\n\")\n\n\n# Seems our insertion sort works\n# however for small/small-medium data/array!\n"
  },
  {
    "path": "algorithms/sorting/selection_sort.py",
    "content": "# -*- coding: utf-8 -*-\n\n# Selection Sort\n# Ideal sorting algorithm for \n# small/small-medium data/array\n\n# temporary parameter tells\n# function to sort a copy of \n# orignal array, and not the array itself\n\n# reverse parameter tells func\n# to sort array in reverse/decending\n# order\n\n\ndef sort_(arr,temporary =False,reverse=False):\n\n    # Making copy of array if temporary is true\n    if temporary:\n        ar = arr[:]\n    else:\n        ar = arr\n\n    # To blend every element\n\t# in correct position\n\t# length of total array is required\n    length = len(ar)\n\n    # After each iteration left-most\n\t# sub-array is completed sorted\n    for i in range(0,length):\n        min = i\n\n        # In each iteration we compare\n        # current element with the right\n        # unsorted sub-array and replace \n        # the minimum/maximum with current\n        # element\n        for j in range(i+1,length):\n\n            # Checking for minimum/maximum\n            if reverse:\n                 if ar[min]<ar[j]:\n                      min = j\n            else:\n                 if ar[min]>ar[j]:\n                      min = j\n       \n       \n        # Replacing minimum/maximum\n        # with current element\n        tmp = ar[i]\n        ar[i]=ar[min]\n        ar[min]=tmp\n    \n    \n\n    # if temporary, then returning\n\t# copied arr's sorted form\n\t# cuz if not returned, then function\n\t# is literally of no use\n    if temporary:\n        return ar\n\n\n# See proper explaination \n# at: https://www.hotdogcode.com/selection-sort/\n\n\n# Testing\ntests = [[7, 8, 9, 6, 4, 5, 3, 2, 1, 15], [1, 90, 1110, 1312, 1110, 98, 76, 54, 32, 10], ] # Add your test cases \n\nfor test in tests:\n\taccend, decend = sort_(test, True), sort_(test, True, True)\n\tif accend == sorted(test) and decend == sorted(test, reverse = True):\n\t\tprint(\"Orignal: {}\".format(test))\n\t\tprint(\"Sorted: {}\".format(accend))\n\t\tprint(\"Sorted(reverse): {}\\n\".format(decend))\n\telse:\n\t\tprint(\"Something went wrong!\\n\")\n\n\n# Seems our selection sort works\n# however for small/small-medium data/array!\n\n"
  },
  {
    "path": "algorithms/string/README.md",
    "content": "\n<pre>\n<i>'string'</i> Sub-directory contains all \n<strong>string related algorithms</strong>\n\n<strong>Thanks</strong>\n</pre>\n"
  },
  {
    "path": "algorithms/string/caesars_cipher_encryption.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\nimport string, sys\r\n\r\n# Caesar's cipher is type of shift cipher, \r\n# an encryption technique\r\n# First used by roman rular Julius Caesar\r\n# To see how it works refer:\r\n# web-page/article: https://en.wikipedia.org/wiki/Caesar_cipher OR \r\n#                   https://www.khanacademy.org/computing/computer-science/cryptography/crypt/v/caesar-cipher\r\n\r\n\r\ndef caesars_cipher_encoding(s, k, lowercase = True, uppercase = False):\r\n\t\r\n\t# To encrypt plain text in either \r\n\t# uppercase letters or lowercase letters\r\n\tif lowercase:\r\n\t\talphas = list(string.lowercase)\r\n\telif uppercase:\r\n\t\talphas = list(string.uppercase)\r\n\r\n\tencrypted = \"\"\r\n\t# List characters in orignal string\r\n\tchar_s = list(s)\r\n\r\n\t# Shifting of each single \r\n\t# character in orignal string\r\n\t# using given key\r\n\tfor char in char_s:\r\n\r\n\t\t# avoid encryption of spaces\r\n\t\tif char == \" \":\r\n\t\t\tencrypted += \" \"\r\n\t\t\r\n\t\telse:  \r\n\t\t\t# n_index or new index is\r\n\t\t\t# the index of encrypted character\r\n\t\t\tn_index = k + alphas.index(char)\r\n\t\t\t\r\n\t\t\t# if encrypted character is greater than\r\n\t\t\t# length of english alphabets\r\n\t\t\tif n_index > 25:\r\n\r\n\t\t\t\t# Read explaination on line 59\r\n\t\t\t\twhile not n_index <= 25:\r\n\t\t\t\t\tn_index = n_index - 26\r\n\t\t\t\tencrypted += alphas[n_index]\r\n\t\t\t\r\n\t\t\t# simple shift\r\n\t\t\telse:\r\n\t\t\t\tencrypted += alphas[n_index]\r\n\t\t\t\t\r\n\treturn encrypted\r\n\r\n# Explaination of key bigger than 26:\r\n# say we have key 54, \r\n# we add index of char(say 'a') to key, i.e. key = 54 + 1 = 55\r\n# so after first iteration over array of length(26), \r\n# i.e. 55(total iterations to perform) - 26(iterations completed) = 29(iterations left)\r\n# but, 29 is still a big index i.e. 29 > length of array(26)\r\n# so we continue to subtract more 26(iterations), \r\n# i.e. 29(iterations to perform) - (26 iterations done) = 3(remaining)\r\n# so 3 is smaller than length of array and can be used as key, \r\n# i.e. 3 < 26(length of array)\r\n# thus, we reached at index of 3 after 54 iterations over an array of length 26\r\n# bit complicated but read it twice, you'll master it!\r\n\r\n# Test, Playing UI\r\ni = 0\r\nwhile True:\r\n\tif raw_input(\"[{}] Exit(press e), To continue(press c): \".format(i)).lower() == \"c\":\r\n\t\t# Number of times \r\n\t\ti += 1\r\n\r\n\t\t# Input for String and key for char shift\r\n\t\tS, K = raw_input(\"\\nString: \"), int(raw_input(\"Key: \"))\r\n\t\t\r\n\t\t# Results\r\n\t\tprint(\"\\nOrignal string: \" + S + \" ,  Key: \" + str(K))\r\n\t\tprint(\"Encrypted text: \" +  caesars_cipher_encoding(S, K, True, False) + \"\\n\")\r\n\t\r\n\telse:\r\n\t\tsys.exit()\r\n"
  },
  {
    "path": "algorithms/string/check_anagram.py",
    "content": "'''An anagram is a word or phrase created by rearranging the letters of another word or phrase.\r\nFor example, the word \"heart\" can be rearranged to form the word \"earth\". \r\nSo, \"heart\" and \"earth\" are anagrams of each other.'''\r\n\r\ndef check_anagram(str1,str2):\r\n     # Remove all spaces from both the strings\r\n     # and convert them to lowercase\r\n    str1 = str1.replace(\" \",\"\").lower()\r\n    str2 =str2.replace(\" \",\"\").lower()\r\n    # if the length of both strings are not equal then return false\r\n    if len(str1) != len(str2):\r\n        return False\r\n    count1 = {}\r\n    count2 = {}\r\n    for i in range(len(str1)):\r\n        count1[str1[i]] = 1+count1.get(str1[i],0)\r\n        count2[str2[i]] = 1+count2.get(str2[i],0)\r\n    for c in count1:\r\n        if count1[c] != count2.get(c,0):\r\n            return False\r\nstr1 = input()\r\nstr2 = input()\r\nif check_anagram(str1,str2):\r\n    print(f\"{str1} and {str2} are anagrams\")\r\nelse:\r\n    print(f\"{str1} and {str2} are anagrams\")"
  },
  {
    "path": "algorithms/string/is_palindrome.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n# Palindrome is a special string, is same if reversed\r\n# e.g. noon, racecar, et cetera\r\n# Notice in above strings, there is no difference between \r\n# string and it's reversed form\r\n\r\n# Function checks if given string is a palindrome or not\r\n# string[::-1] is a clever way to reverse string\r\n# string from start index to end index \r\n# whose difference is -1(reverse)\r\n# found on stack overflow, very pythonic\r\n\r\ndef is_palindrome(s) :\r\n\tif s[::-1] == s:\r\n\t\treturn True\r\n\treturn False\r\n\r\n# Test\r\nS = raw_input(\"String: \")\r\nif is_palindrome(S):\r\n\tprint(\"Results:\\n   \" +S + \" is a palindrome string.\")\r\nelse:\r\n\tprint(\"Results:\\n   \" + S + \" is not a palindrome string.\")\r\n\r\n# add a loop to play many times(maybe infinite)\r\n"
  },
  {
    "path": "algorithms/string/is_palindrome_two_liner.py",
    "content": "\n\nimport string\n\ndef is_palindrome(s):\n\t# String Clenasing\n\ts = \"\".join([char for char in list(s.lower()) if char in list(string.ascii_lowercase)])\n\t\n\t# (index+1) * -1 gives negative index of corresponding counterpart\n\t# for e.g. s = \"noon\"  s[0] = s[-1] = \"n\"  and so on \n\t#  all() and list comprehensions make task so easy!!\n\treturn all([s[index]==s[(index+1)*-1] for index in range(0, len(s))])\n\n\n# Tests\nprint(is_palindrome(\"racecar\"))\nprint(is_palindrome(\"ra cec, a?r   \"))  // True\nprint(is_palindrome(\"noooonnn\"))\nprint(is_palindrome(\"cool..eh\")\n"
  },
  {
    "path": "algorithms/string/vowel_count.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\nimport sys\r\n\r\n# The function\r\n# counts number of occurrences of vowels\r\n# in given string\r\n\r\n# Principle:\r\n# Loop through list of vowels\r\n# count occurrences of each vowel in given string\r\n# yield/generate the occurrences of that vowel\r\n\r\ndef vowel_count(S):\r\n\tvowels = ['a', 'e', 'i', 'o', 'u']\r\n\tfor vowel in vowels:\r\n\t\tcounter = 0\r\n\t\tfor char in S:\r\n\t\t\tif char == vowel:\r\n\t\t\t\tcounter += 1\r\n\t\tyield(vowel, counter)\r\n\r\n# CLI\r\n# Testing or Playing Interface\r\nwhile True:\r\n\tusr_input = raw_input(\"\\nPress (e) to Exit\\nor Enter string: \").strip().lower()\r\n\tif not usr_input == \"e\":\r\n\t\tprint(\"> Results: \")\r\n\t\tfor vow, counter in vowel_count(usr_input):\r\n\t\t\tprint(\"  \" + vow + \" > occurred \" + str(counter) + \" times.\")\r\n\telse:\r\n\t\tprint(\"\\nHope you enjoyed!\")\r\n\t\tsys.exit()\r\n"
  },
  {
    "path": "ansi-colors.py",
    "content": "\"\"\"\nansi-colors.py\nPrint 256 ANSI(8bit) color chart\nReference : https://en.wikipedia.org/wiki/ANSI_escape_code\n\n*** Warning!\nIn some terminal/OS environments,\nthis code may display different colors or color may not be displayed properly\n\"\"\"\n\nSTART_ESCAPE_8BIT = \"\\033[38;5;\"\nEND_ESCAPE = \"\\033[0;0m\"\nSQUARE_CHAR = '\\u25A0'\n\n\ndef print_square_8bit(color):\n    print(START_ESCAPE_8BIT + str(color) + 'm' + SQUARE_CHAR + END_ESCAPE, end=\"\")\n\n\nprint(\"System standard colors:       \", end=\"\")\nfor i in range(8):\n    print_square_8bit(i)\nprint()\n\nprint(\"System high intensity colors: \", end=\"\")\nfor i in range(8, 16):\n    print_square_8bit(i)\nprint()\n\nstep = 0\nprint(\"216 Colors: \")\nfor i in range(16, 232):\n    print_square_8bit(i)\n    step += 1\n    if step % 24 == 0:  # Make newline every 24 colors\n        print()\nprint()\n\nprint(\"Grayscale colors: \", end=\"\")\nfor i in range(232, 256):\n    print_square_8bit(i)\nprint()\n"
  },
  {
    "path": "armstrong_number.py",
    "content": "# Python program to check if the number is an Armstrong number with the index of 3 or not\n# for input try numbers 153, 370, 371, 407\n\n# take input from the user\nnum = int(input(\"Enter a number: \"))\n\n# initialize sum\nsum = 0\n# finding the length of num\nn = len(str(num))\n\n# find the sum of the cube of each digit\ntemp = num\nwhile temp > 0:\n   digit = temp % 10\n   sum += digit ** n # power of n\n   temp //= 10\n\n# display the result\nif num == sum:\n   print(num, \"is an Armstrong number.\")\nelse:\n   print(num, \"is not an Armstrong number.\")\n\n\n\n# Originally contribution by denz647\n"
  },
  {
    "path": "bell_number.py",
    "content": "# Contribution by https://github.com/nightwarriorftw\n\n#Python program to print bell number\n#Bell Number:-Let S(n, k) be total number of partitions of n elements into k sets. The value of n’th Bell Number is sum of S(n, k) for k = 1 to n. Value of S(n, k) can be defined recursively as, S(n+1, k) = k*S(n, k) + S(n, k-1)\nA sample Bell triangle is as follows:\n1\n1   3\n3   8   13\n13  23  33  43\n#The code to print the bell triangle is as follows-\n#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\nn=int(input(\"enter the number of bell\"))     #taking value from the user\nbell=0                                       #initialising bell to 'zero'\nk=0                                          #initialising k to 'zero'\nfor i in range(0,n):                         #loop for changing rows from 0 to n\n    for j in range(0,i+1):                   #printing columns\n        if j==0 and i>0:                     #repeating the last number of previous row in new row\n            print(bell,'',end='')            #printing first number of each line\n        else:\n            k=(i**2)+1+bell                  #to generate other numbers of line\n            print(k,'',end='')               #printing other number in lines\n            bell=k                           #updating value of bell \n    print('\\n')                              #for moving into next lines           \nprint(\"last number of bell is\",bell)    \n"
  },
  {
    "path": "bigo_notation.py",
    "content": "# Contribution from https://github.com/Alok070899\n\nfrom math import log\nimport numpy as np\nimport matplotlib.pyplot as plt\n%matplotlib inline\nplt.style.use('bmh')\n\n# Set up runtime comparisons\n\nn = np.linspace(1,10,1000)\nlabels = ['Constant','Logarithmic','Linear','Log Linear','Quadratic','Cubic','Exponential']\nbig_o = [np.ones(n.shape),np.log(n),n,n*np.log(n),n**2,n**3,2**n]\n\n# Plot setup\n\nplt.figure(figsize=(12,10))\nplt.ylim(0,50)\n\nfor i in range(len(big_o)):\n    plt.plot(n,big_o[i],label = labels[i])\n\n\nplt.legend(loc=0)\nplt.ylabel('Relative Runtime')\nplt.xlabel('n')\n"
  },
  {
    "path": "bubble sort.py",
    "content": "'''Bubble Sort\nBubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.\nExample:\nFirst Pass:\n( 5 1 4 2 8 ) –> ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 > 1.\n( 1 5 4 2 8 ) –>  ( 1 4 5 2 8 ), Swap since 5 > 4\n( 1 4 5 2 8 ) –>  ( 1 4 2 5 8 ), Swap since 5 > 2\n( 1 4 2 5 8 ) –> ( 1 4 2 5 8 ), Now, since these elements are already in order (8 > 5), algorithm does not swap them.\n\nSecond Pass:\n( 1 4 2 5 8 ) –> ( 1 4 2 5 8 )\n( 1 4 2 5 8 ) –> ( 1 2 4 5 8 ), Swap since 4 > 2\n( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )\n( 1 2 4 5 8 ) –>  ( 1 2 4 5 8 )\nNow, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.\n\nThird Pass:\n( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )\n( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )\n( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )\n( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )'''\n\n# Python program for implementation of Bubble Sort\n\ndef bubbleSort(arr):\n\tn = len(arr)\n\n\t# Traverse through all array elements\n\tfor i in range(n):\n\n\t\t# Last i elements are already in place\n\t\tfor j in range(0, n-i-1):\n\n\t\t\t# traverse the array from 0 to n-i-1\n\t\t\t# Swap if the element found is greater\n\t\t\t# than the next element\n\t\t\tif arr[j] > arr[j+1] :\n\t\t\t\tarr[j], arr[j+1] = arr[j+1], arr[j]\n\n# Driver code to test above\narr = [64, 34, 25, 12, 22, 11, 90]\n\nbubbleSort(arr)\n\nprint (\"Sorted array is:\")\nfor i in range(len(arr)):\n\tprint (\"%d\" %arr[i]),\n"
  },
  {
    "path": "cartesian_plane_quadrant.py",
    "content": "# quadrant determiner\r\n# I(+,+) II(-,+) III(-,-) IV(+,-)\r\n\r\ndef determine_quadrant(x, y):\r\n\ttry:\r\n\t\tif x > 0 and y > 0:\r\n\t\t\treturn 'I(+,+)' \r\n\t\telif x < 0 and y > 0:\r\n\t\t\treturn 'II(-,+)'\r\n\t\telif x < 0 and y < 0 :\r\n\t\t\treturn 'III(-,-)'\r\n\t\telif x > 0 and y < 0 :\r\n\t\t\treturn 'IV(+,-)'\r\n\t\telse :\r\n\t\t\treturn 'Invalid parameters were provided'\r\n\texcept TypeError:\r\n\t\treturn \"X and Y co-ords must be integers and not X {}, Y{}\".format(type(x), type(y))\r\n\r\n# Test\r\nresult = determine_quadrant(float(input('X co-ordinate: ')), float(input('Y co-ordinate: ')))\r\nprint(\"Quadrant is \" + result)\r\n"
  },
  {
    "path": "client_file.py",
    "content": "import socket\r\nserver_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)\r\nhost = socket.gethostbyname(socket.gethostname())\r\nport = 12345\r\nx = input(\"Enter file name : \")\r\nserver_socket.connect((host,port))\r\nname = server_socket.recv(1024).decode()\r\nname = name.split('.')[-1]\r\nname = x+'.'+name\r\n\r\nf = open(name,'wb')\r\nwhile True :\r\n    c_msg = server_socket.recv(1024)\r\n    if c_msg == 'EOF'.encode() : \r\n        f.close()\r\n        server_socket.close()\r\n        break\r\n    f.write(c_msg)\r\n\r\n\r\n"
  },
  {
    "path": "conways.py",
    "content": "'''\n-conway's game of life\n-made by Tzara Northcut @Mecknavorz\n-requires pygame\n'''\n\n#import the stuff we need\nimport pygame, sys, time\n\n#-----------------------------------------\n#initalize some variables and other things\n#-----------------------------------------\nwidth = 6 #cell size width\nheight = 6 #cell size height\nspace = 2 #thickness of world lines\n#create the 2d array where we actually store vairables of cells\nworld = [[0 for x in range(100)] for y in range(100)]\n\n#initialzie pygame\npygame.init()\n\nsize = [100*(width+space)+space, 100*(height+space)+space] #window size\nscreen = pygame.display.set_mode(size) #make the window the right size\n\n#set spme colors\nBLACK = (  0,   0,   0) #background color\nWHITE = (255, 255, 255) #color of world\nGREEN = (  0,   0,   0) #color of cells that are alive and well\nRED = (255,   0,   0) #colors of the cells about to die\n\n#speed stuff\nclock = pygame.time.Clock() #clock used to manage game speed\npause = True #used to control the steps, might not need this\nlaststep = time.time()\n\n#used to keep runing until the game is closed\ndone = False\n\n#-------------------------------------\n#some functions to be used in the game\n#-------------------------------------\n#determine #of cells nearby\ndef getclose(x, y):\n    nearby = 0\n    #avoid out of bounds error and make the grid a torroid\n    if(x+1) > 99:\n        x = 0\n    if(y+1) > 99:\n        y = 0\n    #swcan nearby squares and if there's something there add 1 to the count\n    if world[x-1][y-1]:\n        nearby += 1\n    if world[x][y-1]:\n        nearby += 1\n    if world[x+1][y-1]:\n        nearby += 1\n    if world[x-1][y]:\n        nearby += 1\n    if world[x+1][y]:\n        nearby += 1\n    if world[x-1][y+1]:\n        nearby += 1\n    if world[x][y+1]:\n        nearby += 1\n    if world[x+1][y+1]:\n        nearby += 1\n    return nearby\n\n#calculate next step\ndef nextStep():\n    for x in range(len(world)):\n        for y in range(len(world[0])):\n            near = getclose(x, y)\n            if near < 2: #if there are less than two neighbors then kill the cell\n                world[x][y] = 0\n            if near > 3: #if there are more than three neighbors then kill the cell\n                world[x][y] = 0\n            if (world[x][y] == 0) and (near == 3): #if there are 3 neighbors near a dead cell, revive it\n                world[x][y] = 1\n\n#clear the board\ndef clear():\n    for x in range(len(world)):\n        for y in range(len(world[0])):\n            world[x][y] = 0\n\n#---------------------\n#the initale game loop\n#---------------------\nwhile not done:\n    #to make sure the game quits when we need it to\n    for event in pygame.event.get():\n        if event.type == pygame.QUIT:\n            done = True\n        elif event.type == pygame.MOUSEBUTTONDOWN: #if we get a click\n            pos = pygame.mouse.get_pos() #find where the click was\n            #change the pixel coords into game coords\n            x = pos[1] // (height+space)\n            y = pos[0] // (width+space)\n            #add or remove the cell that's there\n            if world[x][y] == 0: #if the tile is empty add a cell\n                world[x][y] = 1\n                #print(\"nearby: \", getclose(x, y)) #used for debugging\n            else: #else if there's something there, remove the cell\n                world[x][y] = 0\n            #print(\"click: \", pos, \"grid coord: \", x, y) #debug stuff\n        elif event.type == pygame.KEYDOWN: #pause the game when space is pressed\n            if event.key == pygame.K_SPACE:\n                #print('space pressed')\n                if pause:\n                    pause = False\n                elif not pause:\n                    pause = True\n            elif event.key == pygame.K_RIGHT: #if we presws the right key go forward a step\n                nextStep() #calculate the next\n            elif event.key == pygame.K_ESCAPE:\n                clear()\n            \n\n    #draw the world\n    screen.fill(BLACK)\n    #maybe move this to a seprate function to help with effeciency?\n    for x in range(len(world)):\n        for y in range(len(world[0])):\n            color = WHITE\n            if world[x][y] == 1:\n                color = GREEN\n            pygame.draw.rect(screen, color, [(space+width)*y+space, (space+height)*x+space, width, height])\n\n    #set frame rate\n    clock.tick(60)\n    if (not pause) and ((time.time() - laststep) > .1):\n        laststep = time.time()\n        #print(laststep)\n        nextStep()\n    #update screen\n    pygame.display.flip()\n\n#if we;ve gotten this far (eg out of the while loop) we know it's time to quit\npygame.quit()\n"
  },
  {
    "path": "count_algorithm_execution_time.py",
    "content": "from datetime import datetime\n\n\n# Don't confuse this is \"Main\" algorithm\n# Time calculated is near accurate because of some extra instructions \n# before actually executing the algorithm\ndef count_cpu_microtime(func_name, *args):\n\ttmp = [i for i in args]\n\tt1 = datetime.now().microsecond\n\tfunc_name(*tmp)\n\ttime_took = datetime.now().microsecond - t1\n\treturn round(time_took, 5)\n\t\n\n# Testing\n\n# \"Test\" algorithm\ndef binary_search(array, n):\n\tarr = sorted(array)\n\tto_return = False \n\tfirst_elem = 0\n\tlast_elem = len(arr) - 1\n\twhile (first_elem <= last_elem):\n\t\tmid = (first_elem + last_elem) // 2\n\t\tif (arr[mid] == n):\n\t\t\tto_return = True\n\t\t\tbreak\n\t\telse:\n\t\t\tif (n > arr[mid]):\n\t\t\t\tfirst_elem = mid + 1\n\t\t\telse:\n\t\t\t\tlast_elem = mid - 1\n\treturn to_return\t\n\nresult = count_cpu_microtime(binary_search, [12,324,23,213,3,2,1], 1)\nprint(str(result) + \" microsecs\")\n"
  },
  {
    "path": "days_you_lived.py",
    "content": "# We assume that given dates are correct\n# and \n# solved for problem set in cs course on udacity.com\nfrom calendar import isleap\n\ndef daysBetweenDates(year1, month1, day1, year2, month2, day2):\n    dom = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n    domleap = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n    if (isleap(year1) and isleap(year2)):\n        e1 = sum(domleap) + sum(domleap[:month1 - 1]) + day1\n        e2 = sum(domleap) + sum(domleap[:month2 - 1]) + day2\n        return e2 - e1\n    \n    days = 0\n    if isleap(year1):\n        days += (sum(domleap[month1 - 1:]) - day1) + sum(dom[:month2 - 1]) + day2 \n    elif isleap(year2):\n        days += (sum(dom[month1 - 1:]) - day1) + sum(domleap[:month2 - 1]) + day2 \n    else:\n        days += (sum(dom[month1 - 1:]) - day1) + sum(dom[:month2 - 1]) + day2 \n    for year in range(year1 + 1, year2):\n        if isleap(year):\n            days += sum(domleap)\n        else:\n            days += sum(dom)\n    return days\n    \n\ndate1=input(\"Enter a first date in YYYY-MM-DD format\")\nyear1,month1,day1=map(int,date1.split('-'))\n\ndate2=input(\"Enter a second date in YYYY-MM-DD format\")\nyear2,month2,day2=map(int,date2.split('-'))\n\ndays=daysBetweenDates(year1, month1, day1, year2, month2, day2)\nprint(\"Number of days between {} and {} is \\n  {}\".format(date1,date2,abs(days)))\n"
  },
  {
    "path": "deMorgans_law.py",
    "content": "# Morgans Formula In Algebra Set operations\r\n# number(set A) + number(set B) - number(set A interaction B)\r\n# n(a)+ n(b) - n(anb)\r\n# you can add sets or increase the number elements of sets The formula still works\r\n\r\na = { 1 , 23 , 55 , 76 , 13 , 90 , 34 , 78 }\r\nb = { 12 , 345 , 8 , 4 , 0 , 7 , 4 , 3 , 53 , 4 , 6 , 3 }\r\n\r\nabInteraction = a & b      # & operator interacts two sets\r\nabUnion = a | b    # | operator makes union of two sets\r\n\r\neqn = len(a) + len(b) - len(abInteraction)\r\nprint(str(eqn) + ' = ' + str(len(abUnion)))\r\n"
  },
  {
    "path": "decimal_to_binary_converter.py",
    "content": "# For concatenation\ndef concat(S):\n\tres = \"\"\n\tfor i in S:\n\t\tif not isinstance(i, str):\n\t\t\tres += str(i)\n\t\telse:\n\t\t\tres += i\n\treturn res \n\n# Simple Base 10 number(Decimal) number converter to Base 2 number(binary) number\n# Function returns answer in str datatype\n# For understanding steps: http://www.electronics-tutorials.ws/binary/bin_2.html\ndef decimal_to_binary(n):\n\tres = []\n\twhile n != 0:\n\t\tres.append(n % 2)\n\t\tn = n // 2\n\tfinal = concat(res) + \"0\"\n\treturn final[::-1]\n\n\n# Test\ncases = [123, 23455, 253552, 87985, 3479434, 76, 246572, 231, 69, 2, 7, 2, 543]\nfor case in cases:\n\tbuilt_in = str(bin(case))[2:]\n\tmy_func = decimal_to_binary(case)[1:] # For test purposes\n\tif built_in == my_func:\n\t\tprint(\"Decimal: \" + str(case))\n\t\tprint(\"Binary: \" + my_func + \"\\nTest Passed!\\n\")\n\telse:\n\t\tprint(\"Test Failed! Badly!!\\n\")\n"
  },
  {
    "path": "decrypting_caesars_cipher.py",
    "content": "import string \r\n# Note: this decryption function is designed to decrypt messages encrypted by encryption function i wrote(avaliable in this repo)\r\n\r\ndef concat_elements(n):\r\n    res = \"\"\r\n    for i in n:\r\n        res += i \r\n    return res\r\n\r\n\r\ndef decrypt(message, key):\r\n    string_chars = list(string.ascii_uppercase) + list(string.ascii_lowercase) +  list(string.digits) + list(string.punctuation) + [\" \"]\r\n    try:\r\n        splitted_message = list(message)\r\n    except TypeError:\r\n        return \"Expected an string for text!\"\r\n        \r\n    for char in splitted_message:\r\n        try:\r\n            tmp = string_chars[string_chars.index(char) - key]\r\n        except IndexError:\r\n            tmp_key = (string_chars.index(char) + key) +  len(string_chars)\r\n            tmp = string_chars[tmp_key]\r\n        splitted_message[splitted_message.index(char)] = tmp\r\n        \r\n    final = concat_elements(splitted_message)\r\n    return final \r\n    \r\n\r\ndef decrypt_generator(message, n):\r\n    # range(0, 96) because len(string_chars) == 95\r\n    for i in range(0, n + 1):\r\n        case = decrypt(message, i)\r\n        yield case \r\n\r\n# Test \r\ntest_case = \"lq01Ir1I2xyI1ncrn2*\"\r\nresult = decrypt(test_case, 9)\r\nprint(\"Decrypted Text: \" + result, \"\\n\")\r\n\r\n_result = list(decrypt_generator(test_case, 95))\r\nfor res in _result:\r\n    print(\"Possible text: \" + res)\r\n# Look at ninth result\r\n"
  },
  {
    "path": "dictionary.py",
    "content": "global dictionary\r\ndictionary = {}\r\n\r\nclass Dict:\r\n\tdef __init__(self, word, meaning):\r\n\t\tself.word = word\r\n\t\tself.meaning = meaning\r\n\r\n\tdef add_new(self):\r\n\t\tdictionary[self.word] = self.meaning\r\n\t\tprint(\"Word Successfully Added\")\r\n\r\n\tdef delete_word(self):\r\n\t\ttry:\r\n\t\t\tdel dictionary[self.word]\r\n\t\t\tprint(\"Word Successfully Deleted\")\r\n\t\texcept KeyError:\r\n\t\t\tprint(\"The Word Does Not Exist in Dictionary. Try Again!\")\t\r\n\t\t\t\r\n\tdef edit_word(self):\r\n\t\ttry:\r\n\t\t\tdictionary[self.word] = self.meaning\r\n\t\t\tprint(\"Word Was Successfully Edited\")\r\n\t\texcept KeyError:\r\n\t\t\tprint(\"The Word You Trying To Edit Does Not Exist in Dictionary!\")\t\r\n\r\n\tdef view_word(self):\r\n\t\ttry:\r\n\t\t\tprint(dictionary[self.word])\r\n\t\texcept KeyError:\r\n\t\t\tprint(\"The Word is not in Dictionary.\")\r\n\r\n\tdef view_all(self):\t\t\r\n\t\tfor i in dictionary.keys():\r\n\t\t\tprint(f\"{i} : {dictionary[i]}\")\r\n\r\ndef start():\r\n\tget_op = input(\"Add, Delete, Edit, View, View all : \")\r\n\tif get_op in [\"add\", \"Add\"]:\r\n\t\tget_word = input(\"Word to add : \")\r\n\t\tget_meaning = input(\"Meaning : \")\r\n\t\tnew = Dict(get_word, get_meaning)\r\n\t\tnew.add_new()\r\n\r\n\telif get_op in [\"delete\", \"Delete\"]:\t\r\n\t\tget_word_to_del = input(\"Word to delete : \")\r\n\t\tdelete = Dict(get_word_to_del, None)\r\n\t\tdelete.delete_word()\r\n\r\n\telif get_op in [\"edit\", \"Edit\"]:\r\n\t\tget_word_to_edit = input(\"Word to edit : \")\r\n\t\tget_new_meaning = input(\"New meaning : \")\r\n\t\tmean = Dict(get_word_to_edit, get_new_meaning)\r\n\t\tmean.edit_word()\t\r\n\r\n\telif get_op in [\"view\", \"View\"]:\r\n\t\tget_word_to_view = input(\"Word to view : \")\r\n\t\tview = Dict(get_word_to_view, None)\r\n\t\tview.view_word()\r\n\r\n\telif get_op in [\"view all\", \"View All\", \"View all\"]:\r\n\t\tnothing = Dict(None, None)\r\n\t\tnothing.view_all()\r\n\r\n\telse:\r\n\t\tprint(\"Invalid Input. Try again!\")\t\t\t\r\n\r\ndef end():\r\n\tquit()\r\n\r\ndef main():\r\n\twhile True:\r\n\t\ts_or_e = input(\"Start or End : \")\r\n\t\tif s_or_e.lower() == \"start\":\r\n\t\t\tstart()\r\n\t\t\tprint(\"  \")\r\n\t\t\tcontinue\r\n\r\n\t\telse:\r\n\t\t\tend()\t\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\tmain()\t\r\n"
  },
  {
    "path": "difference_testing.py",
    "content": "# We assume that the input always be find_difference_matching(list, list, integer)\r\ndef find_difference_matching(x , y , diff = 0):\r\n\tres = []\r\n\tfor i in range(len(x)):\r\n\t    if abs(x[i] -  y[i]) == diff:\r\n\t\t    res.append((x[i], y[i]))\r\n\treturn res\r\n\r\n# Test\r\na = [12, 10, 123, 76, 9990]\r\nb = [2, 0, 45,66, 10000]\r\nresult = find_difference_matching(a, b, 10)\r\nprint(\"Matches:\")\r\nfor i in result:\r\n    print(\"   \" + str(i))\r\n"
  },
  {
    "path": "discount.py",
    "content": "def percToDiscount(percent , mp):\r\n    discount = percent / 100 * mp\r\n    return('Discount is : ' + str(discount))\r\n\r\nprint('Hello\\n')\r\nprint('Press Enter to exit')\r\nwhile(True):  # I've put counting discount in a loop cause if you want to count on multiple items\r\n    more = str(input('Count or End : '))\r\n    if more == 'Count':\r\n        disCountPerc = float(input('Discount Percent : '))\r\n        marketPrice = float(input('Market Price : '))\r\n        print(percToDiscount(disCountPerc , marketPrice))\r\n        continue\r\n    else:\r\n        quit()\r\n"
  },
  {
    "path": "discountPercent.py",
    "content": "def iLoveDiscount(discount , mp):  # mp is market price\r\n    discountPerc = discount / mp * 100\r\n    return('Discount is ' + str(discountPerc) + '%')\r\n\r\nprint('Hello\\n')\r\nprint('Press Enter to exit')\r\nwhile(True):  # I've put counting discount in a loop cause if you want to count on multiple items\r\n    more = str(input('Count or End : '))\r\n    if more == 'Count':\r\n        disCount = float(input('Discount : '))\r\n        marketPrice = float(input('Market Price : '))\r\n        print(iLoveDiscount(disCount , marketPrice))\r\n        continue\r\n    else:\r\n        quit()\r\n"
  },
  {
    "path": "distance_on_number_line.py",
    "content": "# this is a simple geometric distance formula\r\n# d(x,y) = |x-y| = distance\r\n# where x and y are co-ordinates on a number line\r\n\r\ndef distance(x,y):\r\n   return abs(x-y)\r\n\r\nflag = True\r\nwhile flag:\r\n    usr = str(input(\"start [Y/n]: \")).strip().lower()\r\n    if usr == \"y\":\r\n        print(distance(float(input(\"Value of X co-ordinate: \")), float(input(\"Value of Y co-ordinate: \")) ), \"\\n\")\r\n    else:\r\n        flag = False\r\n"
  },
  {
    "path": "euclids_algorithm.py",
    "content": "# Recursive implementation of Euclidean algorithm \ndef gcd(m, n):\n    \"\"\"\n    Calculates the greatest common divisor (GCD) of two positive integers using the Euclidean algorithm.\n\n    Args:\n        m (int): First positive integer.\n        n (int): Second positive integer.\n\n    Returns:\n        int: The GCD of m and n.\n    \"\"\"\n    (a, b) = (max(m, n), min(m, n))\n    while b != 0:\n        a, b = b, a % b\n    return a"
  },
  {
    "path": "factorial.py",
    "content": "def factorial(n):\n    if n == 0:\n        return 1\n    else:\n        return n * factorial(n-1)\nn=int(input(\"Input a number to compute the factiorial : \"))\nprint(factorial(n))\n"
  },
  {
    "path": "figure determiner.py",
    "content": "while(2==2):\r\n   print(\"_________________________________________________\")\r\n   print(\"\"\"Program can determine till 6 angles only.\r\n   and remember if you have angles less than 6 simply enter 0\"\"\")\r\n   print(\"_________________________________________________\")\r\n   get = int(input(\"Enter first angle:\"))\r\n   print(\"_________________________________________________\")\r\n   get_again = int(input(\"Enter second angle:\"))\r\n   print(\"_________________________________________________\")\r\n   get_again_again = int(input(\"Enter third angle:\"))\r\n   print(\"_________________________________________________\")\r\n   get_it = int(input(\"Enter fourth angle:\"))\r\n   print(\"_________________________________________________\")\r\n   get_it_it = int(input(\"Enter fifth angle:\"))\r\n   print(\"_________________________________________________\")\r\n   getting = int(input(\"Enter sixth angle:\"))\r\n   print(\"_________________________________________________\")\r\n\r\n   if get + get_again + get_again_again + get_it  + get_it_it + getting == 180:\r\n       print(\"The figure is Triangle or linear pair of angles\")\r\n       print(\"_________________________________________________\")\r\n   elif get + get_again + get_again_again + get_it  + get_it_it + getting == 360:\r\n       print(\"The figure is Quadrilateral \")\r\n   elif get + get_again + get_again_again + get_it  + get_it_it + getting == 540:\r\n       print(\"The figure is Pentagon\")      \r\n   elif get + get_again + get_again_again + get_it  + get_it_it + getting == 720:\r\n       print(\"The figure is Hexagon\")      \r\n\r\n   feature = raw_input(\"Start again or End:\")\r\n   if feature == \"Start again\":\r\n       print(\"Starting again...\")\r\n       print(\"Started again\")\r\n       continue\r\n   elif feature == \"End\":\r\n       print(\"Program Ended...\")\r\n       print(\"_________________________________________________\")\r\n       print(\" \")\r\n       break\r\n       \r\n"
  },
  {
    "path": "findLcm.py",
    "content": "# function to find lcm of two numbers\r\ndef findLcm(i,v):\r\n    if i > v:\r\n        x = i\r\n    else:\r\n        x = v\r\n    while True:\r\n        if (x % i == 0) and (x % v == 0):\r\n            lcm = x\r\n            return(x)\r\n            break\r\n        x = x + 1\r\n\r\n# Main code\r\nwhile(True):\r\n    startOrEnd = str(input('Count lcm or End : '))\r\n    if startOrEnd == 'Count lcm':\r\n        getFirst = float(input('First num : '))\r\n        getSecond = float(input('Second num : '))\r\n        print(findLcm(getFirst , getSecond))\r\n    else:\r\n        quit()\r\n"
  },
  {
    "path": "find_cube_root.py",
    "content": "\n# This method is called exhaustive numeration!\n# I am checking every possible value\n# that can be root of given x systematically\n# Kinda brute forcing\n\ndef find_cube_root(x):\n    if type(x) == str:\n        return \"Expected an integer! Cannot find cube root of an string!\"\n    for i in range(0, x):\n        if i ** 3 == x:\n            return i \n    return \"{} is not a perfect cube\".format(x)\n    \n# Test \nx = 27\nresult = find_cube_root(x)\nprint(\"Cube root of {} is {}\".format(x, result))\n"
  },
  {
    "path": "find_roots.py",
    "content": "\n\n\"\"\"\nHow it works:\n\tThing is simple first we determine the variable in equation;\n\tThen we iterate through given range by user or default range;\n\tFor each iteration we replace the variables in equation to the number;\n\tAt last we return the roots found;\n\"\"\"\n\nfrom string import ascii_letters\n\n\ndef find_variable(string):\n\tsplitted = string.split()\n\tfor i in splitted:\n\t\tif (i in ascii_letters):\n\t\t\treturn i\n\t\telse: continue\n\treturn None\n\n# Input format for function:\n# \"z ** 2 + 97 * z + (-4)\"\n\ndef find_roots(S, rng = [-10000, 10000]):\n\tres = []\n\tfor v in range(rng[0], rng[1]):\n\t\ttry:\n\t\t\ttest_case = S.replace(find_variable(S), str(v))\n\t\texcept Exception as e:\n\t\t\tprint(e)\n\t\t\treturn \"\"\n\t\tif (eval(test_case) == 0):\n\t\t\tres.append(v)\n\t\telse:\n\t\t\tcontinue\n\n\tif (len(res) == 0):\n\t\treturn None\n\treturn res\n\n#testing\n\n\"\"\"\ntest_str = \"x ** 2 + 5 * x - 6\"\nresult = find_roots(test_str, [-10, -2])\nfor i in result:\n\tprint(\"Root of the equation is {}\".format(i))\n\"\"\"\n"
  },
  {
    "path": "find_square_root.py",
    "content": "\n# This method is called exhaustive numeration!\n# I am checking every possible value\n# that can be root of given x systematically\n# Kinda brute forcing\n\ndef find_square_root(x):\n    if type(x) == str:\n        return \"Expected an integer! Cannot find square root of an string!\"\n    for i in range(0, (x/2 )+2):\n        if i ** 2 == x:\n            return i \n    return \"{} is not a perfect square\".format(x)\n    \n# Test \nx = 2\nresult = find_square_root(x)\nprint(\"Square root of {} is {}\".format(x, result))\n"
  },
  {
    "path": "find_square_root_of_imperfect_square.py",
    "content": "# Here I've implemented a method of finding square root of imperfect square \n# Steps (Pseudocode): visit http://burningmath.blogspot.in/2013/12/finding-square-roots-of-numbers-that.html\n# Read the steps carefully or you'll not understand the program!\n\n# To check is number is a perfect square or not\ndef is_perfect_square(n):\n    if isinstance(n, float):\n        return (False, None)\n    for i in range(n + 1):\n        if i * i == n:\n            return (True, i)\n    return (False, None)\n\n# Average \ndef average(*args):\n    hold = list(args)\n    return sum(hold) / len(hold)\n\n# Method  \n# Just implementation of steps on above webpage\ndef sqrt_of_imperfect_square(a, certainty = 6):\n    is_square = is_perfect_square(a)\n    if is_square[0]:\n        return \"{} is a perfect square .It's root is {}.\".format(a, is_square[1])\n    else:\n        a = int(a)\n        tmp = None\n        s1 = max([float(x * x) for x in range(0,a)])\n        while True:\n            s2 = a / s1\n            tmp = average(s1, s2)\n            if not(round(tmp * tmp, certainty) == float(a)):\n                s1 = tmp\n                continue\n            else:\n            \treturn tmp\n        return -1  # This condition will normally never occur\n        \n# Test\ncase = 2613\nres = sqrt_of_imperfect_square(case, 9)\nprint(\"Test case: \" + str(case))\nprint(\"Root: \" + str(res))\nprint(\"Root Squared: \" + str(res * res))\n"
  },
  {
    "path": "geometric_progression_builder.py",
    "content": "\"\"\"\nSimply it just builds a geometric progression on given conditions.\nIterates through t1 till n \nmultiplies last values in list to constant\nappend it back to list \nCOOL!\n\"\"\"\n\ndef build_geo_sequence(start, end, constant):\n\ttemp = [start]\n\ttry:\n\t\tfor i in range(start, end):\n\t\t\ttemp.append(temp[-1] * constant)\n\texcept TypeError as te:\n\t\tprint(te)\n\texcept Exception as e:\n\t\tprint(e)\n\telse:\n\t\treturn temp\n\n# Test \nres = build_geo_sequence(1, 10, 3)\nprint(\"Geo Sequence:\")\nfor i in res:\n\tprint(\"  \" + str(i))\n# Expected -> 1, 3, 9, 27, 81, ....\n# Here a = 1, d = 3\n"
  },
  {
    "path": "healthScore.py",
    "content": "# Health Calculator\r\n\r\n# func to show health score of user\r\ndef healthScore():\r\n\tprint(' ')\r\n\tnumberOfFruits = int(input('Number Of Fruits You Eat in Week : ')) \r\n\tnumberOftimesFastFood = int(input('Number of Times You Eat FastFood in a Week : '))  \r\n\tcigars = int(input('Cigars You Smoke In A Week : ')) \r\n\tworkoutTime = int(input('How Much minutes You Workout EveryDay : '))  \r\n\tbodyMassIndex = int(input('Whats Your BodyMassIndex(BMI) : '))\r\n\tif 18 < bodyMassIndex < 26 :\r\n\t\tprint(' ')\r\n\t\thealthScore = (numberOfFruits + workoutTime + bodyMassIndex ) - (cigars + numberOftimesFastFood) \r\n\t\tprint(healthScore)\r\n\telse :\r\n\t\tprint(' ')\r\n\t\thealthScore = (numberOfFruits + workoutTime) - (cigars + numberOftimesFastFood + bodyMassIndex )\r\n\t\tprint(healthScore)\t\r\n\r\n# main code\r\nwhile True:\r\n\tstartOrEnd = str(input('Start or End : '))\r\n\tif startOrEnd == 'Start':\r\n\t\tprint(healthScore())\r\n\t\tcontinue\r\n\telse :\r\n\t\tquit()\t\r\n"
  },
  {
    "path": "hello_world.py",
    "content": "# printing hello world is a tradition in beginners \n# it is normally used to if check everything is okay\nimport sys\n\n#type 1 sys.stdout.write()\nsys.stdout.write(\"Hello, \")\nsys.stdout.write(\"World!\")\nsys.stdout.write(\"\\n\")\n\n#type 2 print()\nprint(\"Hello, World!\")\n\n#type 3 - format()\n\nword1 = \"Hello\"\nword2 = \"World\"\nprint(\"{} {}\".format(word1, word2))\n\n#type 4 - f-strings\nword1 = \"Hello\"\nword2 = \"World\"\nprint(f\"{word1} {word2} \")\n\n\n#type 5 - join\ncharacters = ['H','e','l','l','o',' ','W','o','r','l','d']\nmessage = \"\".join(characters)\nprint(message)\n\n#type 6 - Dict\nwords = {\"Eng_greeting\": \"Hello\", \"Eng_world\": \"World\"}\nmessage = \" \".join(words.values())\nprint(message)\n\n\n"
  },
  {
    "path": "html_source.py",
    "content": "# Tested in python2.7\r\n# Getting Html text and saving it to a file.\r\nimport urllib\r\n\r\ndef get_html(url , fname):\r\n    try:\r\n        responsive = urllib.urlopen(url)\r\n        save_file = open(fname + '.html' , 'w')\r\n        save_file.write(responsive.read())\r\n        save_file.close()\r\n    except IOError:\r\n        return \"Make sure url entered is correct and valid!\"\r\n    except Exception as e:\r\n        return \"An Error occured, make sure information enerted is correct!\"\r\n    else:\r\n        return \"Html Successfully received and saved in file {}.html\".format(fname)\r\n    # if you want to read the file uncomment this code\r\n    # emp = open(name + \".html\", 'r').read()\r\n    # openFile.close()\r\n    # return emp\r\n\r\nprint('Hello,')\r\nwhile(True):\r\n    start_or_end = str(raw_input('start or end: ')).strip().lower()\r\n    if start_or_end == 'start':\r\n        print(get_html(raw_input('URL: ').strip() , raw_input('file name: ').strip()), \"\\n\")\r\n        continue\r\n    quit()\r\n"
  },
  {
    "path": "identity_matrix_recognizer.py",
    "content": "# from cs 101 course of udacity.com (problem set solved solution)\n\n# Given a list of lists representing a n * n matrix as input, \n# define a  procedure that returns True if the input is an identity matrix \n# and False otherwise.\n\n# An IDENTITY matrix is a square matrix in which all the elements \n# on the principal/main diagonal are 1 and all the elements outside \n# the principal diagonal are 0. \n# (A square matrix is a matrix in which the number of rows \n# is equal to the number of columns)\n\ndef is_identity_matrix(matrix):\n    total_elems = 0\n    last_pos = 0\n    for row in matrix:\n        total_elems += len(row)\n        if row[last_pos] == 1 and row.count(0) == len(row) - 1:\n            last_pos += 1\n        else:\n            return False\n    if total_elems == len(matrix[0]) * len(matrix[0]):\n        return True\n    else:\n        return False\n\n\n# Test Cases:\n\nmatrix1 = [[1,0,0,0],\n           [0,1,0,0],\n           [0,0,1,0],\n           [0,0,0,1]]\nprint is_identity_matrix(matrix1)\n#>>>True\n\nmatrix2 = [[1,0,0],\n           [0,1,0],\n           [0,0,0]]\n\nprint is_identity_matrix(matrix2)\n#>>>False\n\nmatrix3 = [[2,0,0],\n           [0,2,0],\n           [0,0,2]]\n\nprint is_identity_matrix(matrix3)\n#>>>False\n\nmatrix4 = [[1,0,0,0],\n           [0,1,1,0],\n           [0,0,0,1]]\n\nprint is_identity_matrix(matrix4)\n#>>>False\n\nmatrix5 = [[1,0,0,0,0,0,0,0,0]]\n\nprint is_identity_matrix(matrix5)\n#>>>False\n\nmatrix6 = [[1,0,0,0],  \n           [0,1,0,1],  \n           [0,0,1,0],  \n           [0,0,0,1]]\n\nprint is_identity_matrix(matrix6)\n#>>>False\n\nmatrix7 = [[1, -1, 1],\n           [0, 1, 0],\n           [0, 0, 1]]\nprint is_identity_matrix(matrix7)\n#>>>False           \n\n           \n"
  },
  {
    "path": "image_downloader.py",
    "content": "import random\nimport urllib.request\n\nget = str(input(\"Enter url of image to download :  \"))\n\ndef download_image(url):\n    name = random.randrange(1, 1000)\n    full_name = str(name) + \".jpg\"\n    urllib.request.urlretrieve(url, full_name)\n\nprint(download_image(get))\n"
  },
  {
    "path": "in_the_something.py",
    "content": "import random\r\n\r\n# \"The something in something\" program\r\nnoun_lib = [\"cat\",\"dog\",\"lizard\",\"bald\",\"insane guy\",\"CEO\",\"monkey\",\"teacher\",\"ballerina\",\"old man\",\"nerd\",\"lion\",\"alien\",\"elephant\"]\r\nplace_lib = [\"in Hungary\",\"in the toilet\",\"in a car\",\"in a zoo\",\"in a lions cave\",\"in a park\",\"in Norway\",\"in Rio\",\"on Mars\",\"on a tree\",\"on the roof of Burj-Khalifa\"]\r\n\r\nflag = True\r\nwhile flag:\r\n    inp = str(input(\"\\nDo you want more? [Y/n] \"))\r\n    if inp.strip().lower() == \"y\":\r\n        print(\"-> The\" + \" \" + random.choice(noun_lib) + \" \" + random.choice(place_lib) + \".\")\r\n    else:\r\n        flag = False\r\n"
  },
  {
    "path": "item_index.py",
    "content": "\"\"\"Algorithm for finding index of element in an array\"\"\"\r\n\r\ndef index(array, item):\r\n\tindex = 0\r\n\tfound = False\r\n\twhile (not found):\r\n\t\tif (array[index] == item):\r\n\t\t\tfound = True\r\n\t\telse:\r\n\t\t\tindex = index + 1\r\n\treturn index \r\n\r\nprint index([12, 34], 34)\t"
  },
  {
    "path": "kay_sort.py",
    "content": "\"\"\"\r\nThis sort is same as reverse sort by me.\r\nExcept minor changes in first for loop, and\r\ncomparison sign on line 11\r\nAnd function is called kay_sort because\r\nkay is my nickname\r\n\"\"\"\r\n\r\ndef kay_sort(array):\r\n\tprint \"Orignal List : {}\".format(array)\r\n\tfor i in range(len(array)):\r\n\t\tfor n in range(len(array) - 1):\r\n\t\t\ta = array[n]\r\n\t\t\tif (a > array[i]):\r\n\t\t\t\ttem = array[i]\r\n\t\t\t\tarray[i] = a \r\n\t\t\t\tarray[n] = tem \r\n\treturn \"Sorted List : {}\".format(array)\t\t\t\r\n\t\r\nprint kay_sort([123, 4, 123, 4])\t\r\n"
  },
  {
    "path": "lessThanMoreThan.py",
    "content": "nums = [12,34,65,43,21,97,13,57,10,32]\r\nfinalNums = []\r\nmoreFinalNums = []\r\n\r\ndef compareMore(a):\r\n\tfor x in nums:\r\n\t\tif x > a :\r\n\t\t\tc = finalNums.append(x)\r\n\r\ndef compareLess(d):\r\n\tfor x in nums:\r\n\t\tif x < d :\r\n\t\t\tc = moreFinalNums.append(x)\r\n\t\t\r\nget = int(input('To Compare More Than : '))\r\ngetAgain = int(input('To Compare Less Than : '))\r\n\r\nprint('\\nMore Than Values : ')\r\nprint(compareMore(get))\r\nprint(finalNums , '\\n')\r\n\r\nprint('\\nLess Than Values : ')\r\nprint(compareLess(getAgain))\r\nprint(moreFinalNums,'\\n')\r\n\r\n\t\t\t"
  },
  {
    "path": "linear_search.py",
    "content": "# Linear Search or Sequential Search Algorithm\r\n\r\ndef linear_search(array, to_find):\r\n\tpos = 0\t\t\t# Starting position or index\r\n\tto_return = (False, 0)\r\n\twhile (pos < len(array)):\t\t# while index is less than length of array\r\n\t\tif (array[pos] == to_find):\t\t# if array with index of var pos is equal to find\r\n\t\t\tto_return = (True, pos)\t\t\t# no need to break loop cuz return appends func\r\n\t\t\treturn to_return\r\n\t\telse: \r\n\t\t\tpos = pos + 1\t\t# if elem not found continue to next pos \r\n\treturn to_return\r\n\t\r\nnums = [12, 34, 54, 88, 21]\t\t\t\r\nprint linear_search(nums, 88)\t\t\t"
  },
  {
    "path": "listOperations.py",
    "content": "# list operations\r\n# You can create a list by putting elements inside square brackets[]\r\n# lists are capable of containing any type of data\r\n\r\n# a list can contain datas of different datatypes\r\nnumsAndAlphas = ['a',1,'hello',3.14159265359,'are you okay',True,'good',False]\r\n# this is going to work\r\nprint(numsAndAlphas)\r\n\r\n# list accessing\r\n# You can access single items from the list similar to string indexing\r\n# if you dont know string indexing look for my program called stringOperations.py\r\nprint(numsAndAlphas[0])\r\nprint(numsAndAlphas[1:5])\r\nprint(numsAndAlphas[0:])\r\nprint(numsAndAlphas[:6])\r\nprint(numsAndAlphas[:])\r\nprint(numsAndAlphas[2:7:2])\r\nprint(numsAndAlphas[::3])\r\n\r\n# you can add lists too...\r\nlist2 = [2,9,16,25,36,49,64,81,100,144]\r\nnewList = numsAndAlphas + list2\r\n"
  },
  {
    "path": "listOperationsMethods.py",
    "content": "# list operations part 2\r\n\r\nsiliconValley = ['Google','Apple','Dropbox','Facebook','Cisco','Adobe','Oracle','Samsung']\r\nprint(siliconValley)\r\n\r\n# hmm seems like i forgot to add Electronic Arts in the list siliconValley\r\n# This will add the element at the end of the list\r\nsiliconValley.append('Electronic Arts')\r\nprint(siliconValley)\r\n\r\n# thats cool but I want my element at specific position\r\nsiliconValley.insert(5, 'AMD')\r\n# 5 is the position and whatever you add after comma is element\r\n\r\n# Okay enough I want to pop out an element from list and I want to use it in a string\r\n# you have to provide the index of elementyou want to pop out\r\npoppedElement = siliconValley.pop(4)\r\nprint('Popped element is ' + poppedElement)\r\n\r\n# Oops I Samsung isnt in silicon valley, I have to remove Samsung from list\r\n# How am I gonna do thats\r\n# You have to enter the element in parenthesis and not it's index\r\nsiliconValley.remove('Samsung')\r\nprint(siliconValley)\r\n\r\n# I want to sort the list in alphabetical order\r\n# How to do thats\r\n# simple\r\nsiliconValley.sort()\r\n# or\r\nsorted(siliconValley)\r\nprint(siliconValley)\r\n\r\n# I wanted list in reverse alphabetical order\r\n# simple\r\nsiliconValley.sort(reverse = True)\r\n# or\r\nsorted(siliconValley , reverse = True) # seperate the reverse with comma\r\nprint(siliconValley)\r\n\r\n# Okay what if i dont know about the index of an element but i want to print only that element\r\ngoogleIndex = siliconValley.index('Google')\r\nprint(siliconValley[googleIndex])\r\n\r\n# I am tired of watching those elements again and again\r\n# How I am going to do thats\r\n# easy\r\ndel siliconValley\r\nprint(siliconValley) # this should probably give you an NameError\r\n"
  },
  {
    "path": "listReverse.py",
    "content": "getLi = [12,43,7,43,87,89,56,9809,9878,56,78,98,True,56,76]\r\nreverseList = getLi[::-1] # [::-1] tells to step from end without difference\r\nprint(reverseList)\r\n"
  },
  {
    "path": "list_comprehensions.py",
    "content": "list_of_even_squares = [num ** 2 for num in range(0,101,2)]\nprint(list_of_even_squares , \"\\n\")\n\nlist_of_odd_squares = [num ** 2 for num in range(1,102,2)]\nprint(list_of_odd_squares , \"\\n\")\n\nlist_of_even_cubes = [num ** 3 for num in range(0,101,2)]\nprint(list_of_even_cubes , \"\\n\")\n\nlist_of_odd_cubes = [num ** 3 for num in range(1,102,2)]\nprint(list_of_odd_cubes , \"\\n\")\n"
  },
  {
    "path": "logarithm_integer.py",
    "content": "\n# Exhaustive numeration (iteration)\n# Simple implementation of logarithmic function\n# I love math!\n\n# log(b, x) <=> b ** y = x\n# So we have to find y!\n\n# Don't use it for decimal numbers\n# log(1000) or log(e, x) is not automatically avaliable\ndef logarithm_integer(b, x):\n\tif (b > 0 and b != 1) and x > 0:\n\t\tfor i in range(x):\n\t\t\tif b ** i == x:\n\t\t\t\treturn i \n\t\treturn -1\n\telse:\n\t\treturn \"Invalid input for logarithm\"\n\n# Test\nprint(\"log(6, 216) -> \" + str(logarithm_integer(6, 216)))\nprint(\"log(5, 625) -> \" + str(logarithm_integer(5, 25)))\nprint(\"log(4, 16) -> \" + str(logarithm_integer(4, 16)))\nprint(\"log(2, 8) -> \" + str(logarithm_integer(2, 8)))\nprint(\"log(3, 6) -> \" + str(logarithm_integer(3, 6)))\nprint(\"log(0, 16) -> \" + str(logarithm_integer(0, 16)))\n"
  },
  {
    "path": "madLibs.py",
    "content": "# my code may not work with python 3.5 cause it is made for 2.7 version\r\nlibs =[\"Dragon Freak\",\"Excuses\"]\r\n\r\n# precode\r\ndef dragonFreak():\r\n    colorDrag = raw_input(\"Color : \")\r\n    superLatDrag = raw_input(\"Superlative (ending in est) : \")\r\n    adj1Drag = raw_input(\"Adjective : \")\r\n    bodyDragPlu = raw_input(\"Body Part Plural : \")\r\n    bodyDrag = raw_input(\"Body Part : \")\r\n    nounDrag = raw_input(\"Noun : \")\r\n    animalDrag = raw_input(\"Animal(Plural) : \")\r\n    adj2Drag = raw_input(\"Adjective : \")\r\n    adj3Drag = raw_input(\"Adjective : \")\r\n    adj4Drag = raw_input(\"Adjective : \")\r\n    # creating madlib\r\n    fMadLib = '''\r\n    The %s Dragon is the %s Dragon of all. It has %s %s,\r\n    and a %s shaped like a %s. It loves to eat %s,\r\n    although it will feast on nearly anything. It is %s and %s.\r\n    You must be %s around it, or you may end up as it`s meal!\r\n    '''%(colorDrag , superLatDrag , adj1Drag , bodyDragPlu , bodyDrag , nounDrag , animalDrag , adj2Drag , adj3Drag , adj4Drag)\r\n\r\n    print(fMadLib)\r\n\r\ndef excuses():\r\n    place = raw_input(\"Place : \")\r\n    adjExcuse = raw_input(\"Adjective : \")\r\n    bodyPart = raw_input(\"Bodypart : \")\r\n\r\n    fMadLib = '''\r\n    I cannot come to %s ,\r\n    because there is %s %s flu\r\n    ''' %(place , adjExcuse , bodyPart)\r\n    print(fMadLib)\r\n\r\n# main code for user interaction\r\nwhile True:\r\n    startOrEnd = raw_input(\"Start or End : \")\r\n    if startOrEnd.strip() == \"Start\":\r\n        print(libs)\r\n        whichLib = raw_input(\"Which one :\")\r\n        if whichLib.strip() == \"Dragon Freak\":\r\n            print(dragonFreak())\r\n            continue\r\n        elif whichLib.strip() == \"Excuse\":\r\n            print(excuses())\r\n            continue\r\n        else :\r\n            print(\"Not avaliable\")\r\n            continue\r\n    elif startOrEnd.strip() == \"End\":\r\n        print(\"Progarm Ended...\")\r\n        break\r\n"
  },
  {
    "path": "magicball_8.py",
    "content": "import random\r\n\r\ndef magic():\r\n    input(\"Ask me a question . Try me: \")\r\n    return random.choice([ \"It is certain\" , \"Outlook good\" , \"You may rely on it\" , \"Ask again later\" , \"Concentrate and ask again\" , \"Reply hazy, try again\" , \"My reply is no\" , \"My sources say no\" ])\r\n\r\n# main Sector\r\nprint(\"Hello,\")\r\nwhile True:\r\n    if input(\"start or end: \").strip().lower() == \"start\":\r\n        print(magic(), \"\\n\")\r\n        continue\r\n    else:\r\n        quit()\r\n"
  },
  {
    "path": "map_example.py",
    "content": "# Contribution by https://github.com/tyadav4268\n\n#This is to demonstrate the use of map function in python\n#Problem Statement: Using the function Map, count the number of words that start with ‘S’ in input_list.\n#Sample Input: ['Santa Cruz','Santa fe','Mumbai','Delhi']\n#Sample Output: 2\n\n#Solution:\ninput_list = ['Santa Cruz','Santa fe','Mumbai','Delhi']\n\ncount = sum(map(lambda x: x[0] == 'S', input_list))\n\nprint(count)        # Output: 2\n"
  },
  {
    "path": "math/Binary_to_decimal",
    "content": "# binary_to_decimal.py\n#\n# Description: A program to evaluate  binary to decimal.\n#\n# Author: Chaitanya Mittal\n# Date: 2023-11-17 10:14:20.288913\n\n\"\"\"Idea:\n- def a function to decode 1 byte:\n    - get the list\n    - get value by multiplying each element with 2** its index from reverse (pattern observation)\n      .... (instead of this we can multiply index to list reversed)......\n    - return the sum of value\n\n- get input\n- split it to get rid of spaces (assume user is well behaved and will enter 1-space separated string only)\n- convert each byte and compile result in a list\n- print the converted bytes separated by space\n\"\"\"\n\n\ndef byte_decode(binary):\n    # Convert binary string to list\n    lst = list(binary)[::-1]\n    \n    # Initialize variables\n    length = len(binary)\n    sum = 0\n    \n    # Loop through each character in the binary string\n    for i in range(length):\n        # Calculate value of each bit\n        value = int(lst[i]) * (2 ** i)\n        \n        # Add value to the sum\n        sum += value\n    \n    # Return the final sum\n    return sum\n\n#  ____ Main Program  ____ #\n\n# Get input of the required binary string\nbinary = input(\"Binary: \").split(\" \")\n\"\"\"  TESTING PURPOSES\nstring = (\"01010101 01101110 01100100 01100101 0110010 00100000 01011001 01101111 01110101 01110010 00100000 01010011 01100101 01100001 01110100\").split()\nbinary = list(string)\"\"\"\n\n# Initialize an empty list to store 'evaluated' bytes\nbytes_translated = list()\n#translate the byte and append it to the list\nfor byte in binary:\n    bytes_translated.append(byte_decode(byte))\n\n# Print the output\nprint(f'Evaluated: ', end = \"\")\nfor byte in bytes_translated:\n    print(byte, end = \" \")\nprint()\n\n\n        \n"
  },
  {
    "path": "math/FreefallCalculator",
    "content": "# Gravity Simulation\n\nimport math\nimport numpy as np\n\n# Welcome\n\nprint(\"Welcome to a 1D Free Fall Simulation. Please enter only in metric integers. \")\nprint(\"You will enter the amount of time you want to simulate, it includes information about impact, \\n\"\n      \"even if the simulation stops before impact.\")\n\n# Constants\n\ng = 9.81\n\n# Variables\n\nheight = int(input(\"Drop Height: \"))\ntimeElapsed = 1\nrunTime = int(input(\"How long do you want to record data from the fall? \"))\nlocation = 0\nmass = int((input(\"Mass: \")))\ntimeToImpact = 0\n\n# Simulation\n\nprint(\"Second by second info of free fall in given time.\")\nwhile timeElapsed <= runTime and timeToImpact >= 0 and location >= 0:\n\n    # Equations\n\n    distanceTraveled = (g * timeElapsed ** 2) / 2\n    velocity = distanceTraveled / timeElapsed\n    location = height - distanceTraveled\n    momentum = mass * velocity\n    timeToImpact = math.sqrt((2 * height) / g)\n\n    # Print Stats\n\n    print(\"\\nTime to simulation end: \" + str(runTime - timeElapsed))\n    print('Y Location: ' + str(location) + 'M')\n    print('Velocity: ' + str(velocity) + 'M/S')\n    print('Distance Traveled: ' + str(distanceTraveled) + 'M')\n    print('Momentum: ' + str(momentum) + 'N')\n    print('Time Elapsed: ' + str(timeElapsed))\n    print('Rough time to impact: ' + str(timeToImpact - timeElapsed))\n    print()\n\n    # Add to time elapsed\n\n    timeElapsed = timeElapsed + 1\n\n# Print impact results\n\nprint(\"\\n The Simulation is done. \\n\")\nprint(\"*This is printed even if the object fell past the ground, or never hit it.* \\n Info on impact: \")\nprint('Y Location: 0M')\nprint('Velocity: ' + str(height / runTime) + 'M/S')\nprint('Distance Traveled: ' + str(height) + 'M')\nprint('Momentum: ' + str(mass * (height / runTime)) + 'N')\nprint('Time Spent in free fall: ' + str(timeToImpact))\nprint()\n"
  },
  {
    "path": "math/README.md",
    "content": "\n<pre>\n<i>'math'</i> Sub-directory contains all the math related scripts\n<strong>This dir does not contain mathematical algorithms,\nonly math related scripts</strong> \n</pre>\nThe programs have been <strong>re-checked</strong> and <strong>re-mastered</strong> by me!<br>\nAlthough i've tried to keep it as orignal as possible.<br>\nKeep Patience It'll take time to go through every program!!<br>\n<b>Thanks</b>\n"
  },
  {
    "path": "math/aircraft_thrust.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\nimport math\r\n\r\n# Calculating thrust of Aircraft Propeller\r\ndef thrust_props(diameter , velocity , velocity1 , density):\r\n    \r\n    # According to formula\r\n    return math.pi / 4 * diameter ** 2 * (velocity + velocity1/2) * density * velocity1\r\n\r\nprint('Hello Aircraft Lovers,\\n')\r\n\r\nwhile(True):\r\n\t# Loop for continous calculation\r\n    start_or_end = str(raw_input('start or end : ')).strip().lower()\r\n    \r\n    # Main interface\r\n    if start_or_end == 'start':\r\n        res = thrust_props(float(input('\\nDiameter of propeller: ')) , float(input('Velocity of air flow: ')) , float(input('Additional propeller acceleration, velocity: ')) , float(input('Fluid density: ')))\r\n        print(\"\\nThrust of propeller: {}\".format(res)) \r\n    \r\n    else:\r\n        quit()\r\n    print(\"\")\r\n\r\n# found formula on nasa's website\r\n"
  },
  {
    "path": "math/area_volume_calculator.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\nimport math\r\nimport sys\r\n\r\n# Perimeter\r\n# or sum of span of all sides of figure\r\n\r\n# perimeter of square f(s) = 4 * s\r\n# where s is the side of square\r\nperi_of_square = lambda s: 4 * s\r\n\r\n# perimeter of rectangle, f(L, W) = 2 * (L + W) or 2L + 2W\r\n# where L is length, and W is width(breadth) of rectangle\r\nperi_of_rectangle = lambda l, w: 2 * (l + w)\r\n\r\n# perimeter of triangle, f(s1, s2, s3) = s1 + s2 + s3\r\n# where s1, s2, s3, are the sides of a regular triangle\r\nperi_of_triangle = lambda s1, s2, s3: s1 + s2 + s3\r\n\r\n# peri of right angled triangle, f(a, b) = a + b + square_root(a ** 2 + b ** 2)\r\n# since, by pythagoras theoram,\r\n#  a ** 2 + b ** 2 = c ** 2 or a squared + b squared = c squared\r\nperi_of_rt_triangle = lambda a, b: a + b + math.sqrt(a ** 2 + b ** 2)\r\n\r\n# perimeter of circle(or circumference), f(r) = 2 * r * pi\r\n# or f(d) = d * pi, where r is radius, pi is pi ratio(3.14159......), \r\n# d is diameter\r\nperi_of_circle = lambda r: 2 * r * math.pi\r\nperi_of_circle1 = lambda d: d * math.pi \r\n\r\n\r\n# Areas\r\n# or surface area of figure\r\n# how many lengths into widths and vice versa\r\n\r\n# area of square, f(s) = s * s or (s)squared or s ** 2\r\n# where s is the side of square, s is same as both\r\n# length and width of square\r\narea_of_square = lambda s: s ** 2\r\n\r\n# area of rectangle, f(L, W) = L * W\r\n# or length multiplied by width(breadth)\r\narea_of_rectangle = lambda l, w: l * w\r\n\r\n\r\n# area of triangle, f(b, h) = b * h / 2\r\n# where, b is base, and h is the height of triangle\r\n# see: explaination of area of triangle\r\n# here: \r\narea_of_triangle = lambda b, h: (b * h) / 2\r\n\r\n# Heron's formula\r\n# see for more info: https://en.wikipedia.org/wiki/Heron%27s_formula\r\narea_of_triangle1 = lambda a, b, c: math.sqrt((a+b+c)/2 * ((a+b+c)/2 - a) ((a+b+c)/2 - b) ((a+b+c)/2 - c))\r\n\r\n# area of parallelogram, f(b, h) = b * h\r\n# where b is base, h is height of parallelogram\t\r\narea_of_parallelogram = lambda b, h: b * h \r\n\r\n# area of trapezoid(trapezium), f(b1, b2, h) (b1 + b2) / 2 * h\r\n# where, b1 is base 1, b2 is base 2, and h is height\r\narea_of_trapezoid = lambda b1, b2, h: (b1 + b2) / 2 * h\r\n\r\n# area of circle, f(r) = pi * r ** 2\r\n# where r is radius, pi is math constant of pi(C/D)\r\n# see explaination of formula: \r\n# http://pythagoreanmath.com/complete-explanation-for-area-of-a-circle-formula/\r\narea_of_circle = lambda r: math.pi * r ** 2\r\n\r\n\r\n# Terminal UI\r\ni = 0\r\nwhile True:\r\n\tif raw_input(\"\\n[{}] Exit(press e), Continue(press c): \".format(i)).lower() == \"c\":\r\n\t\t\r\n\t\twhich_fig = raw_input(\"\\nSquare(s), Rectangle(r), Triangle(t), right(|_)led triangle(rt), Parallelogram(pa), Cricle(ci), Trapezoid(tr): \").lower()\r\n\r\n\t\tif which_fig == \"s\":\r\n\t\t\tif raw_input(\"\\nArea(press a) or Perimeter(press p): \").lower() == \"a\":\r\n\t\t\t\tprint(\"\\tArea of square: \" + str(area_of_square(float(raw_input(\"Side of square: \")))))\r\n\t\t\telse:\r\n\t\t\t\tprint(\"\\tPerimeter of square: \" + str(peri_of_square(float(raw_input(\"Side: \")))))\r\n\r\n\t\telif which_fig == \"r\":\r\n\t\t\tif raw_input(\"\\nArea(press a) or Perimeter(press p): \").lower() == \"a\":\r\n\t\t\t\tprint(\"\\tArea of rectangle: \" + str(area_of_rectangle(float(raw_input(\"Length: \")), float(raw_input(\"Width: \")))))\r\n\t\t\telse:\r\n\t\t\t\tprint(\"\\tPerimeter of rectangle: \" + str(peri_of_rectangle(float(raw_input(\"Length: \")), float(raw_input(\"Width: \")))))\r\n\r\n\t\telif which_fig == \"t\":\r\n\t\t\tif raw_input(\"\\nArea(press a) or Perimeter(press p): \").lower() == \"a\":\r\n\t\t\t\tif raw_input(\"\\nBy Heron's Formula[y/n]: \").lower() == \"y\":\r\n\t\t\t\t\tprint(\"\\tArea of triangle(Heron's Formula): \" + str(area_of_triangle1(float(raw_input(\"A: \")), float(raw_input(\"B: \")), float(raw_input(\"C: \")))))\r\n\t\t\t\telse:\r\n\t\t\t\t\tprint(\"\\tArea of triangle: \" + str(area_of_triangle(float(raw_input(\"Base: \")), float(raw_input(\"Height: \")))))\r\n\t\t\telse:\r\n\t\t\t\tprint(\"\\tPerimeter of triangle: \" + str(peri_of_triangle(float(raw_input(\"A: \")), float(raw_input(\"B: \")), float(raw_input(\"C: \")))))\r\n\t\t\r\n\t\telif which_fig == \"rt\":\r\n\t\t\tif raw_input(\"\\nArea(press a) or Perimeter(press p): \").lower() == \"a\":\r\n\t\t\t\tprint(\"\\tArea of triangle: \" + str(area_of_triangle(float(raw_input(\"Base: \")), float(raw_input(\"Height: \")))))\r\n\t\t\telse:\r\n\t\t\t\tprint(\"\\tPerimeter or right angled triangle: \" + str(peri_of_rt_triangle(float(raw_input(\"A: \")), float(raw_input(\"B: \")))))\r\n\t\t\t\r\n\t\telif which_fig == \"pa\":\r\n\t\t\tif raw_input(\"\\nArea(press a) or Perimeter(press p): \").lower() == \"a\":\r\n\t\t\t\tprint(\"\\tArea of parallelogram: \" + str(area_of_parallelogram(float(raw_input(\"Base: \")), float(raw_input(\"Height: \")))))\r\n\t\t\telse:\r\n\t\t\t\tprint(\"\\tPerimeter of parallelogram: \" + str(peri_of_rectangle(float(raw_input(\"Length: \")), float(raw_input(\"Width: \")))))\r\n\t\t\r\n\t\telif which_fig == \"tr\":\r\n\t\t\tif raw_input(\"\\nArea(press a) or Perimeter(press p): \").lower() == \"a\":\r\n\t\t\t\tprint(\"\\tArea of trapezoid: \" + str(area_of_trapezoid(float(raw_input(\"Base 1: \")), float(raw_input(\"Base 2: \")), float(raw_input(\"Height: \")))))\r\n\t\t\telse:\r\n\t\t\t\tprint(\"\\tPerimeter of trapezoid: \" + str(peri_of_triangle(float(raw_input(\"Side1: \")), float(raw_input(\"Side4: \")), float(raw_input(\"Side3: \"))) + float(raw_input(\"Side1: \"))))\r\n\t\t\t\r\n\t\telif which_fig == \"c\":\r\n\t\t\tif raw_input(\"\\nArea(press a) or Perimeter(press p): \").lower() == \"a\":\r\n\t\t\t\tprint(\"\\tArea of circle: \" + str(area_of_circle(float(raw_input(\"Radius: \")))))\r\n\t\t\telse:\r\n\t\t\t\tif raw_input(\"\\nUsing Radius(r) or Diameter(d): \").lower() == \"r\":\r\n\t\t\t\t\tprint(\"\\tCircumference of circle: \" + str(peri_of_circle(float(raw_input(\"Radius: \")))))\r\n\t\t\t\telse:\r\n\t\t\t\t\tprint(\"\\tCircumference of circle: \" + str(peri_of_circle1(float(raw_input(\"Diameter: \")))))\r\n\r\n\t\ti += 1\r\n\r\n\telse:\r\n\t\tsys.exit()\r\n"
  },
  {
    "path": "math/arithmetic_progression_builder.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Arithmetic progressions\n# are special types of sets(more of a series)\n# where the difference between every consecutive\n# numbers of series is constant or common\n# for more refer: https://en.wikipedia.org/wiki/Arithmetic_progression\n\n# formula for general term of arithmetic prog.\n# tn = a + (n - 1) * d\n# where, \n#    tn -> is the n(th) term, \n#\t a -> if the first term, \n#    d -> is the common difference \n\n# Third param 'n_last' refers to limit or length or index of last term\n\ndef arithmetic_p_sequence_builder(a, d, n_last):\n\n\t# To generate an A.P. length should be\n\t# greater than or equal to 1\n\tif n_last < 1:\n\t\treturn -1\n\n\tseq = []\n\n\t# Every item is obtained by\n\t# applying the general term formula\n\tfor n in range(1, n_last + 1):\n\t\tseq.append(a + (n - 1) * d)\n\t\t\n\treturn seq \n\n# Test\nprint(\"Arithmetic progression: {}\".format(arithmetic_p_sequence_builder(int(raw_input(\"A(a, first term): \")), int(raw_input(\"D(d, common difference): \")), int(raw_input(\"N(n, length): \")))))\n\n# Although big line, but works just fine!\n"
  },
  {
    "path": "math/calculator.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\nimport sys\n\n# Functions to apply basic arithmetic\n# operations on 2 numbers \n# Each func, takes 2 numbers as input\n\nadd = lambda a, b: a + b \nsubtract = lambda a, b: a - b \nmultiply = lambda a, b: a * b \ndivide = lambda a, b: a / b \nmodulus = lambda a, b: a % b \n\n# CLI\n# Testing/Playing Interface\ni = 0\nwhile True:\n\tif raw_input(\"\\n\\n[{}] Exit(press e) or Calculate(press c): \".format(i)) == \"c\":\n\t\top = raw_input(\"\\nAdd(press a), Subtract(press s), Multiply(press m),\\nDivide(press d), Modulus(press mo): \").strip().lower()\n\t\tif op == \"a\":\n\t\t\tprint(\"  Sum: \" + str(add(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\n\t\telif op == \"s\":\n\t\t\tprint(\"  Subtracted: \" + str(subtract(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\n\t\telif op == \"m\":\n\t\t\tprint(\"  Multiplied: \" + str(multiply(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\n\t\telif op == \"d\":\n\t\t\tprint(\"  Divided: \" + str(divide(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\n\t\telse:\n\t\t\tprint(\"  Modulus: \" + str(modulus(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\n\t\ti += 1\n\telse:\n\t\tprint(\"\\nHope you enjoyed!\")\n\t\tsys.exit()\n"
  },
  {
    "path": "math/decimal_to_binary_converter.py",
    "content": "\"\"\"\nI came up with this algorithm to convert decimal(natural numbers only xd) to binary completely from scratch and \ntherefore it might not be the best most efficient implementation.\nOptimizations are welcome.\n\"\"\"\n\ndef dec_to_bin(n):\n    quo = n \n    binary = 0\n    while (quo>0):\n        tmp = quo\n        pows = 0\n        while (quo > 1):\n            quo = quo // 2\n            pows = pows + 1 \n        quo = tmp-pow(2,pows)\n        binary = binary+pow(10,pows)\n    return binary\n\nfor i in range(0,101):\n    print(\"Natural Number:\"+str(i)+\" Binary:\"+str(dec_to_bin(i)))\n"
  },
  {
    "path": "math/eulers_python.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\n# By formula derived by Euler(A great mathematician)\r\nprint(\"Euler's Formula: F(faces) + V(vertices) = E(Edges)+2\\n\")\r\n\r\n# Further derivation\r\nprint(\"Derivation 1: E(Edges) = F(faces)+V(vertices) - 2\")\r\nprint(\"Derivation 2: V(vertices) = E(edges)+2 - F(Faces)\")\r\nprint(\"Derivation 3: F(faces) = E(edges)+2 - V(vertices)\")\r\n\r\n\r\n# By order of operations, parenthesis can be added \r\n# for ensuring, but not needed\r\ndef E(f, v):\r\n\treturn f+v - 2\r\n\r\ndef V(e, f):\r\n\treturn e+2 - f \r\n\r\ndef F(e, v):\r\n\treturn e+2 - v\r\n\r\n\r\n# function to evaluate\r\n# By default datatype of raw_input() is string\r\nuser = raw_input(\"\\nE, V or F: \").upper()\r\nprint(\" \")\r\n\r\n\r\n# evaluating function asked by user\r\nif user == \"E\":\r\n\tprint(\"\\nEdges: \" + str(E(input(\"Faces: \"), input(\"Vertices: \"))))\r\nelif user == \"V\":\r\n\tprint(\"\\nVertices: \" + str(V(input(\"Edges: \"), input(\"Faces: \"))))\r\nelif user == \"F\":\r\n\tprint(\"\\nFaces: \" + str(F(input(\"Edges: \"), input(\"Vertices: \"))))\r\nelse:\r\n\tprint(\"Invalid Input, Try again!\")\r\n\r\n\r\n# A while loop can be added \r\n# to perform multiple calculations\r\n"
  },
  {
    "path": "math/geoMean.py",
    "content": "# Add path, encoding\r\n\r\nimport math\r\n\r\n\r\n# Geometric Mean:\r\n# Calculates the geometric mean of \r\n# two numbers \r\n# formula: f(x, y) = square_root(x*y)\r\n\r\ngeoMean = lambda x, y: math.sqrt(x*y)\r\n\r\n\r\nwhile True:\r\n\tif input(\"Start [Y/n]?  \").strip().lower() == \"y\":\r\n\t\tprint(\" [Res] = \" + str(geoMean(float(input(\"\\nX? \")), float(input(\"Y? \")))) + \"\\n\\n\")\r\n\telse:\r\n\t\tprint(\"\\n\\nGoodBye!\")\r\n\t\tbreak\r\n"
  },
  {
    "path": "math/number_lesser_greater.py",
    "content": "\r\nimport sys\r\n\r\n# Use of \r\n# Conditionals in python\r\n# Determines weather the number is positive negative or zero\r\ndef pos_neg_zero(x): \r\n\tif x < 0:  return \"Negative\" \r\n\telif x > 0:  return \"Positive\" \r\n\treturn \"Zero\"\r\n\r\nwhile True:\r\n\tif str(raw_input(\" Start [Y/n]?  \")).strip().lower()== \"y\":\r\n\t\tprint(\"    [Num] = \" + pos_neg_zero(float(raw_input(\" Number:  \"))) + \"\\n\")\r\n\telse:\r\n\t\tprint(\"Bye!\")\r\n\t\tsys.exit(0)\r\n"
  },
  {
    "path": "mathoperators.py",
    "content": "# maths sucks make it cool with python\r\n# math operators\r\n\r\n# INTEGERS\r\n# integers are whole numbers positive or negative\r\n# + operator adds numbers\r\nadd = 24 + 1004\r\n# - operator subtracts second number from First\r\nsubtract = 546 - 132\r\n# * multiplies numbers\r\nmultiply = 90 * 4\r\n# / divides numbers\r\ndivide = 36/6\r\n# returns the remainder of the division\r\nmodulo = 17 % 3\r\n\r\n# FLOAT\r\n# floats are decimal point numbers positive or negative\r\naddFloat = 24.5 + 1004.005\r\nsubtractFloat = 546.90 - 132.56\r\nmultiplyFloat = 90.0 * 4.2\r\ndivideFloat = 36.6 / 6.6\r\nmoduloFloat = 17.0 % 3.0\r\n\r\n# all operators work same on both floats or integers\r\n"
  },
  {
    "path": "max_by_alphabetical_order.py",
    "content": "\nimport string \n\ndef lower_(arr):\n\t\"\"\"\n\tFor conversion of every element in list to lower \n\t\"\"\"\n\tfor i in range(len(arr)):\n\t\tarr[i] = arr[i].lower()\n\ndef max_alphabetical_order(s):\n\t\"\"\"\n\tUseful on lists containing strings that start from alphabets,\n\tbecause the algorithm is written for it in the first place!\n\t\"\"\"\n\tcopy = s[:]\n\tuseful = list(string.ascii_lowercase)\n\tlower_(s)\n\tres = s[0]\n\tfor word in s[1:]:\n\t\ttmp = word[0]\n\t\tif useful.index(tmp) > useful.index(res[0]):\n\t\t\tres = word\n\treturn copy[s.index(res)]\n\t\n# Test\ncase1 = [\"Alpha\", \"Beta\", \"Gist\", \"exotic\", \"hells kitchen\", \"word\", \"Ultra\", \"zip\"]\ncall = max_alphabetical_order(case1)\nprint(\"Max element in list by alphabet order:\\n\" + call)\n"
  },
  {
    "path": "max_int_in_list.py",
    "content": "\r\ndef  compare(li):\r\n\tres = 0\r\n\tfor i in range(len(li) - 1):\r\n\t\ta = li[i]\r\n\t\tb = li[i + 1]\r\n\t\tif (a > b):\r\n\t\t\tif (a > res):\r\n\t\t\t\tres = a \r\n\t\telse:\r\n\t\t\tif (b > res):\r\n\t\t\t\tres = b\t\r\n\treturn res \r\n\t\r\ndef convert():\t\r\n\tget_input = raw_input(\"Enter Space Seperated Numbers : \")\r\n\traw = get_input.split()\r\n\tnums = []\r\n\tfor i in raw:\r\n\t\tnums.append(float(i))\r\n\treturn nums\r\n\r\nif __name__ == \"__main__\":\t\r\n\tprint compare(convert())\t\t"
  },
  {
    "path": "min_by_alphabetical_order.py",
    "content": "\nimport string \n\ndef lower_(arr):\n\t\"\"\"\n\tFor conversion of every element in list to lower \n\t\"\"\"\n\tfor i in range(len(arr)):\n\t\tarr[i] = arr[i].lower()\n\ndef min_alphabetical_order(s):\n\t\"\"\"\n\tUseful on lists containing strings that start from alphabets,\n\tbecause the algorithm is written for it in the first place!\n\t\"\"\"\n\tcopy = s[:]\n\tuseful = list(string.ascii_lowercase)\n\tlower_(s)\n\tres = s[0]\n\tfor word in s[1:]:\n\t\ttmp = word[0]\n\t\tif useful.index(tmp) < useful.index(res[0]):\n\t\t\tres = word\n\treturn copy[s.index(res)]\n\t\n# Test\ncase1 = [\"Alpha\", \"Beta\", \"Gist\", \"exotic\", \"hells kitchen\", \"word\", \"Ultra\", \"zip\"]\ncall = min_alphabetical_order(case1)\nprint(\"Max element in list by alphabet order:\\n\" + call)\n"
  },
  {
    "path": "min_int_in_list.py",
    "content": "\r\ndef  compare(li):\r\n\tif (len(li) == 1):\r\n\t\treturn \"Single Value To Compare {} in List\".format(li[0])\r\n\tres = 0\r\n\tfor i in range(len(li) - 1):\r\n\t\ta = li[i]\r\n\t\tb = li[i + 1]\r\n\t\tif (a < b):\r\n\t\t\tif (i != 0): \r\n\t\t\t\tif (a < res):\r\n\t\t\t\t\tres = a\r\n\t\t\telse:\r\n\t\t\t\tres = a \t\r\n\t\telse:\r\n\t\t\tif (i != 0):\r\n\t\t\t\tif (b < res):\r\n\t\t\t\t\tres = b\r\n\t\t\telse:\r\n\t\t\t\tres = b\t\r\n\treturn res \r\n\t\r\ndef convert():\t\r\n\tget_input = raw_input(\"Enter Space Seperated Numbers : \")\r\n\traw = get_input.split()\r\n\tnums = []\r\n\tfor i in raw:\r\n\t\tnums.append(float(i))\r\n\treturn nums\r\n\r\nif __name__ == \"__main__\":\t\r\n\tprint compare(convert())\t\t\r\n"
  },
  {
    "path": "mod_example.py",
    "content": "import random\r\nimport urllib.request\r\n\r\ndef downloadImage(url):\r\n    filename = str(random.randrange(1,1000))\r\n    download = urllib.request.urlretrieve(url, filename)\r\n\r\ndownloadImage()\r\n\r\n"
  },
  {
    "path": "modified_selection_sort.py",
    "content": "\"\"\"\r\nMy Modified Solution to Selection Sort Algorithm,\r\ninstead of swapping elem it is appended to another\r\ntemporary array. This makes algotrihm less complicated.\r\n\"\"\"\r\n\r\ndef selection_sort(array):\r\n\ttemp_num = len(array)\r\n\ttemp_arr = []\r\n\twhile (len(temp_arr) != temp_num):\r\n\t\ta = min(array)\r\n\t\ttemp_arr.append(a)\r\n\t\tdel array[array.index(a)]\r\n\treturn temp_arr\r\n\r\n# Test\r\ntest_case = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]\t\r\nprint(\"By Builtin method: {}\".format(sorted(test_case)))\r\nprint(\"By SelectionSort method: {}\".format(selection_sort(test_case)))\r\n"
  },
  {
    "path": "morse_code_decoder.py",
    "content": "def decodeMorse(morseCode):\r\n    # ToDo: Accept dots, dashes and spaces, return human-readable message\r\n    morse_code = {\".-\" : \"A\",\r\n                  \"-...\" : \"B\",\r\n                  \"-.-.\" : \"C\",\r\n                  \"-..\" : \"D\",\r\n                  \".\" : \"E\",\r\n                  \"..-.\" : \"F\",\r\n                  \"--.\" : \"G\",\r\n                  \"....\" : \"H\",\r\n                  \"..\" : \"I\",\r\n                  \".---\" : \"J\",\r\n                  \"-.-\" : \"K\",\r\n                  \".-..\" : \"L\",\r\n                  \"--\" : \"M\",\r\n                  \"-.\" : \"N\",\r\n                  \"---\" : \"O\",\r\n                  \".--.\" : \"P\",\r\n                  \"--.-\" : \"Q\",\r\n                  \".-.\" : \"R\",\r\n                  \"...\" : \"S\",\r\n                  \"-\" : \"T\",\r\n                  \"..-\" : \"U\",\r\n                  \"...-\" : \"V\",\r\n                  \".--\" : \"W\",\r\n                  \"-..-\" : \"V\",\r\n                  \"-.--\" : \"Y\",\r\n                  \"--..\" : \"Z\",\r\n                  \".----\" : \"1\",\r\n                  \"..---\" : \"2\",\r\n                  \"...--\" : \"3\",\r\n                  \"....-\" : \"4\",\r\n                  \".....\" : \"5\",\r\n                  \"-....\" : \"6\",\r\n                  \"--...\" : \"7\",\r\n                  \"---..\" : \"8\",\r\n                  \"----.\" : \"9\",\r\n                  \"-----\" : \"0\",\r\n                  \"SPACE\" : \" \"}\r\n    morseCode.strip()\r\n    new = morseCode.replace(\"   \", \" SPACE \")\r\n    prep = new.split() \r\n    res = \"\"\r\n    li = list(morse_code.keys())\r\n    for n in prep:\r\n        elif n in li:\r\n            res = res + morse_code[n]\r\n        \r\n        else:\r\n            pass    \r\n    return res.strip()\r\n"
  },
  {
    "path": "multiplicationTables.py",
    "content": "# Multiplication Table viewer\r\n\r\nwhile True:\r\n\tstartOrEnd = str(input('Start or End : '))\r\n\tif startOrEnd == 'Start':\r\n\t\twhichTable = int(input('Which Table : '))\r\n\t\tfor x in range(1, 13):\r\n\t\t\ttable =  whichTable * x\r\n\t\t\tprint(table)\r\n\t\tcontinue\r\n\telse :\r\n\t\tprint('Program Ended...')\r\n\t\tbreak\t\r\n"
  },
  {
    "path": "my_name.py",
    "content": "# Example of accessing elements in list\r\n\r\ninside = list(\"abcdefghijklmnopqrs tuvwyxyz\")\r\nprint (inside[10] + inside[0] + inside[11] + inside[15] + inside[0] + inside[10] + inside[19] + inside[20] + inside[0] + inside[10] + inside[4])\r\n\t\t\r\n"
  },
  {
    "path": "nearest_square_and_its_root.py",
    "content": "# Find the nearest root and its square\n\ndef nearest_square(n):\n    i = 0\n    found = False\n    while (not found):\n        if i ** 2 <= n < ((i + 1) ** 2):\n            found = True\n        else:\n            i += 1\n    return (i, i ** 2)\n    \n# Test\ncase = 40\nres = nearest_square(case)\nprint(\"Nearest square to {}: \\n{}\".format(case, res[1]))\n"
  },
  {
    "path": "network/are_you_connected_to_world.py",
    "content": "\n\nimport os\nimport sys\nimport webbrowser\nfrom time import sleep as sleep_sheep \n\n\n# Executing ping with input host\n# using systems functionality (only linux)\ndef ping(host):\n\tinstr = \"ping -c 1 %s\" %(host) \n\tresponse = os.system(instr)\n\treturn response == 0\n\n\n# Finite state loop if \n# computer re-connects to network\n# else will run till re-conn\ndef you_cant_be_dead(host):\n\tif (not ping(host)):\n\t\t# Status update\n\t\tprint(\"  [.] Status -> Not connected to network\")\n\t\tprint(\"  / CONSTANTLY Re-CHECKING CONNECTIVITY... /\")\n\t\twhile (True):\n\t\t\tif not ping(host): continue\n\t\t\telse: break\n\n\t\t\t# Connectivity is checked \n\t\t\t# every 7 secs\n\t\t\tsleep_sheep(7)\n\n\treturn True\n\n\ndef exit_(status):\n\tif (status == 0 or status == 1):\n\t\tprint(\"\\n ~ See you soon!\")\n\t\tsys.exit(status)\n\telse:\n\t\treturn None\n\n\n# User \n# Shell Interface\nwhile True:\n\tif raw_input(\"\\nStart [Y/n]? \").strip().lower() == \"y\":\n\t\tinp = raw_input(\"URI (alive) HOST: \").strip()\n\t\tprint(\"\\n > CHECKING CONNECTION...\\n > Host -> %s\\n\" % inp)\n\t\t\n\t\tif you_cant_be_dead(inp):\n\t\t\t# When connected to internet\n\t\t\t# Status update, and proof of connection\n\t\t\tprint(\"\\n  [.] Status -> CONNECTED to network\")\n\t\t\twebbrowser.open(\"https://www.youtube.com/watch?v=JbjIH5pvT5A\")\n\t\t\texit_(0)\n\n\telse:\n\t\texit_(0)\n"
  },
  {
    "path": "newOnContacts.py",
    "content": "# pre code\r\n# main list of contacts\r\ncontacts = {}\r\n\r\n# funcs of pre code\r\n# func to add new contact\r\ndef newContact():\r\n    while True:\r\n        newContact = raw_input(\"Name for new Contact : \")\r\n        numForNewContact = raw_input(\"Number for Contact : \")\r\n        add = raw_input(\"Add or Try again :\")\r\n        if add.strip() == \"Add\":\r\n            contacts[newContact] = numForNewContact\r\n            print(\"Contact Successfully added.\")\r\n            break\r\n        elif add.strip() == \"Try again\":\r\n            continue\r\n        else :\r\n            print(\"Invalid Input.try again\")\r\n            continue\r\n        startAgain = raw_input(\"Add more or continue : \")\r\n        if startAgain.strip() == \"Add more\":\r\n            print(\" \")\r\n            continue\r\n        elif startAgain.strip() == \"continue\":\r\n            print(\" \")\r\n            break\r\n\r\n# func to search for a contact\r\ndef searchContact():\r\n    while True:\r\n        search = raw_input(\"Search for contact : \")\r\n        toShow = str(search) + contacts[search]\r\n        print(toShow)\r\n        startAgain = raw_input(\"Search more or continue : \")\r\n        if startAgain.strip() == \"Search more\":\r\n            print(\" \")\r\n            continue\r\n        elif startAgain.strip() == \"continue\":\r\n            print(\" \")\r\n            break\r\n\r\n# func to edit a contact\r\ndef editContact():\r\n    while True:\r\n        whichToEdit = raw_input(\"Name of Contact of which Number to Edit : \")\r\n        contacts[whichToEdit] = raw_input(\"Number to add : \")\r\n        startAgain = raw_input(\"Edit more or continue : \")\r\n        if startAgain.strip() == \"Edit more\":\r\n            print(\" \")\r\n            continue\r\n        elif startAgain.strip() == \"continue\":\r\n            print(\" \")\r\n            break\r\n\r\n# main code to interact\r\nwhile True:\r\n    print(\"hello,\".title())\r\n    # part of main code to start or end\r\n    startOrEnd = raw_input(\"Start or End : \")\r\n    if startOrEnd.strip() == \"Start\":\r\n        # part of main code to control functions\r\n        addSearchEdit = raw_input(\"Add or Search or Edit : \")\r\n        if addSearchEdit.strip() == \"Add\":\r\n            print(newContact())\r\n        elif addSearchEdit.strip() == \"Search\":\r\n            print(searchContact())\r\n        elif addSearchEdit.strip() == \"Edit\":\r\n            print(editContact())\r\n        else :\r\n            print(\"Invalid Input . Try Again\")\r\n            continue\r\n    elif startOrEnd.strip() == \"End\":\r\n        print(\"Ending...\")\r\n        break\r\n    else :\r\n        print(\"Invalid Input . Try Again\")\r\n        continue\r\n    # part of main code to start again or end\r\n    startAgain = raw_input(\"Start again or End : \")\r\n    if startAgain.strip() == \"Start again\":\r\n        print(\"Starting  again...\")\r\n        continue\r\n    elif startAgain.strip() == \"End\":\r\n        print(\"Ending program...\")\r\n        break\r\n    else :\r\n        break\r\n"
  },
  {
    "path": "non_multiples.py",
    "content": "number_to_check = int(input(\"Number : \"))\ntill_where = int(input(\"Till where to check : \"))\nlist_of_non_multiples = []\nfor num in range(0, till_where + 1):\n\tif num % number_to_check != 0:\n\t\tlist_of_non_multiples.append(num)\n\t\t\nprint(list_of_non_multiples)\n# or you can do \n# this\nprint(\" \")\nfor element in list_of_non_multiples:\n\tprint(element)\n"
  },
  {
    "path": "ordered_binary_search.py",
    "content": "def binary_search(array, n):\r\n\tarr = sorted(array)\r\n\tto_return = False \r\n\tfirst_elem = 0\r\n\tlast_elem = len(arr) - 1\r\n\twhile (first_elem <= last_elem):\r\n\t\tmid = (first_elem + last_elem) // 2\r\n\t\tif (arr[mid] == n):\r\n\t\t\tto_return = True\r\n\t\t\tbreak\r\n\t\telse:\r\n\t\t\tif (n > arr[mid]):\r\n\t\t\t\tfirst_elem = mid + 1\r\n\t\t\telse:\r\n\t\t\t\tlast_elem = mid - 1\r\n\treturn to_return\t\t\t\r\n\r\n\r\ndef Ordered_binary_search(arra, elem):\r\n\tif (len(arra) == 0):\r\n\t\treturn False\r\n\t\r\n\tmiddle = len(arra) // 2\t\r\n\tif (arra[middle] == elem):\r\n\t\treturn True \r\n\telse:\t\r\n\t\tif (elem > arra[middle]):\r\n\t\t\treturn binary_search(arra[middle:], elem)\r\n\t\telse: \r\n\t\t\treturn binary_search(arra[:middle], elem) \t\r\n\t\t\r\nnums = [0,23,54,5,32,78]\t\r\nprint Ordered_binary_search(nums, 32)\t\r\nprint Ordered_binary_search(nums, 5)\t\r\n"
  },
  {
    "path": "otherAngle.py",
    "content": "def complementary():\r\n\twhile(True):\t\r\n\t\tcomplementary = float(input('Complementary of : '))\r\n\t\tif complementary <= 90:\r\n\t\t\tcomplement = 90 - complementary\r\n\t\t\treturn(complement)\r\n\t\t\tbreak\r\n\t\telse:\r\n\t\t\tprint('Number greater than 90 degree. Try again')\r\n\t\t\tcontinue\r\n\r\ndef supplementary():\r\n\twhile(True):\t\r\n\t\tsupplementary = float(input('Supplementary of : '))\r\n\t\tif supplementary <= 180:\r\n\t\t\tsupplement = 180 - supplementary\r\n\t\t\treturn(supplement)\r\n\t\t\tbreak\r\n\t\telse:\r\n\t\t\tprint('Number greater than 180 degree. Try again')\r\n\t\t\tcontinue\t\t\r\n\r\nwhile(True):\r\n\tcountOrEnd = str(input('Count or End : '))\r\n\tif countOrEnd.strip() == 'Count':\r\n\t\tprint('\\nSupp for supplementary\\nComp for complementary')\r\n\t\tgetSuppOrCom = str(input('Supp or Comp : '))\r\n\t\tif getSuppOrCom.strip() == 'Supp':\r\n\t\t\tprint(supplementary())\r\n\t\t\tcontinue\r\n\t\telif getSuppOrCom.strip() == 'Comp':\r\n\t\t\tprint(complementary())\r\n\t\t\tcontinue\r\n\t\telse:\r\n\t\t\tbreak\r\n\telse:\r\n\t\tquit()\t\t\t\r\n"
  },
  {
    "path": "password_creator.py",
    "content": "\"\"\"\r\nWhy to create strong password?\r\nBecause it makes the chances of hackers bruteforcing your password to almost 0%\r\nSimply to not get hacked!\r\n\"\"\"\r\n\r\nimport random\r\nimport string\r\n\r\n# Password level is Strong!\r\n# Creates a alphanumeric password of `n` chars \r\ndef create_password(n):\r\n    allChars = list(string.ascii_letters) + list(string.digits) + list(string.punctuation)\r\n    passphrase = []\r\n    for i in range(n):\r\n        tmp = random.choice(allChars)\r\n        passphrase.append(tmp)\r\n    \r\n    res = \"\".join(passphrase)\r\n    return res\r\n    \r\n# Test 1\r\ntest1 = create_password(16)\r\nprint(test1)\r\n\r\n# Test 2 \r\ntest2 = create_password(32)\r\nprint(test2)\r\n"
  },
  {
    "path": "percentageCalc.py",
    "content": "# Percentage Calculator\r\ndef percentToOrig():\r\n\twhatPercent = float(input('What Percent : '))\r\n\tofWhat = float(input('Of What Percent : '))\r\n\torignal = whatPercent / 100 * ofWhat\r\n\tprint(orignal)\r\n\r\nprint(percentToOrig())\t"
  },
  {
    "path": "percentage_increase_decrease.py",
    "content": "# Percantage Increase , Percentage Decrease\r\n\r\ndef increasePercent(increase , origValue):\r\n    return(str(increase / origValue * 100) + '%')\r\n\r\ndef decreasePercent(decrease , origValue):\r\n    return(str(decrease / origValue * 100) + '%')\r\n\r\nprint('Hello,\\nPress Enter To Exit')\r\nincOrDec = str(input('increase or decrease: ')).strip().lower()\r\nif incOrDec == 'increase':\r\n    print(increasePercent(float(input('Increased Value : ')) ,  float(input('Orignal Value : '))))\r\nelif incOrDec == 'decrease':\r\n    print(increasePercent(float(input('Increased Value : ')), float(input('Orignal Value : '))))\r\nelse:\r\n    quit()\r\n"
  },
  {
    "path": "physics.py",
    "content": "# physics calcy\r\n\r\noperations = [ \"Preassure\" , \"Force\" , \"Speed\" , \"Velocity\" , \"Accelaration\" , \"Momentum\" ]\r\n\r\n#pre code sector I\r\n# preassure function to calculate preassure\r\ndef preassure():\r\n    print(\" \")\r\n    force = int(raw_input(\"Enter force : \"))\r\n    print(\" \")\r\n    area = int(raw_input(\"Enter area : \"))\r\n    preassure = force / area\r\n    print(\" \")\r\n    print(\"Preassure is \" + str(preassure) + \"pascal\")\r\n\r\n# force function to calculate force\r\ndef force():\r\n    print(\" \")\r\n    mass = int(raw_input(\"Enter mass : \"))\r\n    print(\" \")\r\n    accelaration = int(raw_input(\"Enter accelaration : \"))\r\n    force = mass * accelaration\r\n    print(\" \")\r\n    print(\"Force is \" + str(force) + \"newton\")\r\n\r\n# speed func to calculate speed of object\r\ndef speed():\r\n    print(\" \")\r\n    distance = int(raw_input(\"Enter distance : \"))\r\n    print(\" \")\r\n    time = int(raw_input(\"Enter time taken : \"))\r\n    speed = distance / time\r\n    print(\" \")\r\n    print(\"Speed of object is \" + str(speed))\r\n\r\n# velocity func to calculate velocity of object\r\ndef velocity():\r\n    print(\" \")\r\n    displacement = int(raw_input(\"Enter displacement : \"))\r\n    print(\" \")\r\n    time = int(raw_input(\"Enter time taken : \"))\r\n    velocity = displacement / time\r\n    print(\" \")\r\n    print(\"Velocity of object is \" + str(velocity))\r\n\r\n# accelaration func to calculate accelaration\r\ndef accelaration():\r\n    print(\" \")\r\n    initialV = int(raw_input(\"Enter initial velocity : \"))\r\n    print(\" \")\r\n    finalV = int(raw_input(\"Enter final velocity : \"))\r\n    print(\" \")\r\n    time = int(raw_input(\"Enter time taken : \"))\r\n    acce = (finalV - initialV) / time\r\n    print(\" \")\r\n    print(\"Accelaration is \" + str(acce) + \"m/s sq.\")\r\n\r\n# monentum func to calculate momentum\r\ndef moment():\r\n    print(\" \")\r\n    mass = int(raw_input(\"Enter mass : \"))\r\n    print(\" \")\r\n    velocity = int(raw_input(\"Enter velocity : \"))\r\n    print(\" \")\r\n    momentum = mass * velocity\r\n    print(\" \")\r\n    print(\"Momentum is \" + str(momentum))\r\n\r\n# CLI code sector II\r\n\r\nwhile True:\r\n    print(\" \")\r\n    print(\"Hello\")\r\n    print(\" \")\r\n    startOrEnd = raw_input(\"Start or End : \")\r\n    print(\" \")\r\n    if startOrEnd.strip() == \"Start\" :\r\n        for op in operations:\r\n            print(op)\r\n            print(\" \")\r\n\r\n        main = raw_input(\"Which operation : \")\r\n        if main.strip() == \"Preassure\":\r\n            print(preassure())\r\n            continue\r\n        elif main.strip() == \"Force\":\r\n            print(force())\r\n            continue\r\n        elif main.strip() == \"Speed\":\r\n            print(speed())\r\n            continue\r\n        elif main.strip() == \"Velocity\":\r\n            print(velocity())\r\n            continue\r\n        elif main.strip() == \"Accelaration\":\r\n            print(accelaration())\r\n            continue\r\n        elif main.strip() == \"Momentum\":\r\n            print(moment())\r\n            continue\r\n        else :\r\n            print(\"Invalid operation\")\r\n            continue\r\n    elif startOrEnd.strip() == \"End\":\r\n        print(\"...Progarm Ended...\")\r\n        break\r\n"
  },
  {
    "path": "pigLatin.py",
    "content": "# Pig Latin Word Altering Game\r\n# function to convert word in pig latin form\r\ndef alterWords():\r\n\twordToAlter = str(input('Word To Translate : '))\r\n\talteredWord = wordToAlter[1:] + wordToAlter[0:2] + 'y' # translating word to pig latin\r\n\tif len(wordToAlter) < 46 :\r\n\t\tprint(alteredWord)\r\n\telse :\r\n\t\tprint('Too Big . Biggest Word in English Contains 45 characters.')\r\n\r\n# main interaction code \r\nwhile True:\r\n\tstartOrEnd = str(input('Start or End : '))\r\n\tif startOrEnd == 'Start':\r\n\t\tprint(' ')\r\n\t\tprint(alterWords())\r\n\t\tcontinue\r\n\telse :\r\n\t\tquit()\t\t\t "
  },
  {
    "path": "piggyBank.py",
    "content": "# piggy bank\r\n# pre code\r\nmoney = 0\r\n\r\n# function to add money to current amount\r\ndef addMoney():\r\n    print(\" \")\r\n    userAdd = float(raw_input(\"Add money : \"))\r\n    print(\" \")\r\n    money = money + userAdd\r\n    print(\"After adding current Money you have is \" + str(money) + \" rupees\")\r\n\r\n# function to withdraw money from current amount\r\ndef withdrawMoney():\r\n    print(\" \")\r\n    userWithdraw = float(raw_input(\"Add money : \"))\r\n    print(\" \")\r\n    money = money + userWithdraw\r\n    print(\"After adding current Money you have is \" + str(money) + \" rupees\")\r\n\r\n# function to display current amount\r\ndef currentMoney():\r\n    print(\" \")\r\n    current = \"Current money you have is \" + str(money) + \" rupees\"\r\n\r\n# main code\r\nprint(\" \")\r\nprint(\"--------------------Start-------------------\")\r\nwhile True:\r\n    print(\" \")\r\n    user = raw_input(\"Start or End : \")\r\n    if user.strip() == \"Start\":\r\n        controlPiggy = raw_input(\"Add Withdraw or Check : \")\r\n        if controlPiggy.strip() == \"Add\":\r\n            print(addMoney())\r\n            continue\r\n        elif controlPiggy.strip() == \"Withdraw\":\r\n            print(withdrawMoney())\r\n            continue\r\n        elif controlPiggy.strip() == \"Check\":\r\n            print(currentMoney())\r\n            continue\r\n        else :\r\n            print(\" \")\r\n            print(\"Invalid Input.Try again\")\r\n            continue\r\n\r\n    elif user.strip() == \"End\" :\r\n        print(\" \")\r\n        print(\"------------Program Ended-----------\")\r\n        print(\" \")\r\n        break\r\n\r\n    else :\r\n        print(\" \")\r\n        print(\"Invalid Input. Try again\")\r\n        continue\r\n"
  },
  {
    "path": "ping_host.py",
    "content": "\nimport os\nimport platform as plt\n\ndef ping_host(host_name):\n\tping_str = \"-c 1\"\n\tif plt.system().lower() == \"Windows\":\n\t\tping_str = \"-n 1\"\n\tping = \"ping \" + ping_str + \" \" + host_name\n\tresp = os.system(ping)\n\treturn resp == 0\n\t\n# Test \ntest_host = \"www.google.co.in\"\nresult = ping_host(test_host)\nif result:\n\tprint(\"\\nStatus ({}): Is Alive\".format(test_host))\nelse:\n\tprint(\"\\nStatus ({}): Is Dead\".format(test_host))\n"
  },
  {
    "path": "primeNumbers.py",
    "content": "# Prime number Determiner\r\n# replace input() with raw_input() in Python version 2.7 input() works with version 3 \r\nimport math as Math\r\n\r\nPOSITIVE_MESSAGE = \" is a prime number\"\r\nNEGATIVE_MESSAGE = \" is not a prime number\"\r\n\r\n\r\ndef is_number_prime(number):\r\n    \"\"\"\r\n    Function which checks whether the number is a prime number or not\r\n    :param number: integer - to be checked for prime-ness\r\n    :return: boolean - true if prime, else false\r\n    \"\"\"\r\n\r\n    \"\"\"\r\n    This is the main logic behind reducing the numbers to check for as factors\r\n        if N = a * b; where a<=b and a,b C (1, N)\r\n        then, a * b >= a*a;\r\n        which leads to => a*a <= N\r\n                       => a <= sqrt(N)\r\n    Hence checking only till the square root of N \r\n    \"\"\"\r\n    upper_lim = Math.floor(Math.sqrt(number)) + 1\r\n    is_prime = True if number != 1 else False\r\n\r\n    for i in range(2, upper_lim):\r\n        if number % i == 0:\r\n            is_prime = False\r\n            break\r\n            # The moment there is a divisor of 'number', break the iteration, as the number is not prime\r\n\r\n    return is_prime\r\n\r\n\r\nwhile True:\r\n    startOrEnd = str(input('Start or End : '))\r\n    if startOrEnd == 'Start':\r\n        number = int(input('Number to Check : '))\r\n        result = str(number)\r\n        prime_status = is_number_prime(number)\r\n\r\n        if prime_status:\r\n            result += POSITIVE_MESSAGE\r\n        else:\r\n            result += NEGATIVE_MESSAGE\r\n        print(result)\r\n    else:\r\n        print('Program Ended...')\r\n        break\r\n"
  },
  {
    "path": "profitLoss.py",
    "content": "# Profit Loss Calculator\r\n\r\ndef profit(sellP , costP):\r\n    profit = sellP - costP\r\n    return(profit)  # Function for calculating profit\r\n\r\ndef loss(costP , sellP):\r\n    loss = costP - sellP\r\n    return(loss)    # Function for calculating loss\r\n\r\ndef profitPercent(prof , costP):\r\n    profitPerc = prof / costP * 100\r\n    return(str(profitPerc) + '%') # func to calculate profit percent\r\n\r\ndef lossPercent(loss , costP):\r\n    lossPerc = loss / costP * 100\r\n    return(str(lossPerc) + '%') # Func to calculate loss percent\r\n\r\nprint('Hello\\n')\r\nprint('Press Enter To Exit')\r\nwhile(True):\r\n    google = str(input('Profit or Loss : '))\r\n    if google.strip() == 'Profit': # condition for profit\r\n        sellPrice = float(input('Selling Price : ')) # getting selling price\r\n        costPrice = float(input('Cost Price : ')) # getting costprice\r\n        if sellPrice > costPrice:   # if selling price is greater than cp\r\n            print('Profit : ' + str(profit(sellPrice , costPrice)))\r\n            print('Profit Percent : ' + str(profitPercent(profit(sellPrice , costPrice) , costPrice)))\r\n            continue\r\n        else: # else if sp is less than cp so it is loss\r\n            print('Cost Price is Greater Than Selling Price')\r\n            print('Try calculating loss\\n')\r\n            continue\r\n    elif google.strip() == 'Loss':\r\n        costPrice = float(input('Cost Price : '))\r\n        sellPrice = float(input('Selling Price : '))\r\n        if costPrice > sellPrice:\r\n            print('Loss : ' + str(loss(costPrice , sellPrice)))\r\n            print('Loss Percent : ' + str(lossPercent(loss(costPrice , sellPrice) , costPrice)))\r\n            continue\r\n        else:\r\n            print('Selling Price is Greater Than Cost Price')\r\n            print('Try calculating profit\\n')\r\n            continue\r\n    else:\r\n        quit()\r\n"
  },
  {
    "path": "pyKeywords.py",
    "content": "# Checking is some keyword is a python keyword or not\r\nimport keyword\r\n\r\npythonKeywords = keyword.kwlist\r\ngetToCheck = str(input('Keyword to check : '))\r\ncheck = keyword.iskeyword(getToCheck)\r\nif check == True:\r\n    print(getToCheck + ' is a python keyword.')\r\nelse:\r\n    print(getToCheck + ' is not a python keyword.')\r\n\r\nprint('\\nShowing all keywords in python : \\n')\r\nprint(pythonKeywords)\r\n# remember to test the code\r\n"
  },
  {
    "path": "pythagoras.py",
    "content": "# Pythagoras Formula\r\nimport math\r\n# a.sq + b.sq = c.sq\r\n\r\na = float(input('Value for A : '))\r\nb = float(input('Value for B : '))\r\nc = math.sqrt(a ** 2 + b ** 2)\r\n# here's the answer\r\nprint(c)"
  },
  {
    "path": "python_files_compiler.py",
    "content": "from cx_Freeze import setup, Executable\r\n\r\n# file must be saved in same directory as the file you want to Compile\r\n# Download cx_Freeze from source forge or run easy_install in power shell\r\n\r\nnameOfExec = input(\"Name for Executable: \")\r\nversionNumber = input(\"Version: \")\r\nauth = input(\"Name of Author: \")\r\nauth_email = input(\"Email of Author: \")\r\ndescript = input(\"Description: \")\r\nfilename = input(\"File to Compile(Add .py to file): \")\r\n\r\n# run this file in cmd \"python CompileFiles.py build\" or \"python CompileFiles.py build_exe\"\r\n# This setup in minimialistic\r\n\r\nsetup(\r\n    name = nameOfExec,\r\n    version = versionNumber,\r\n    description = descript, \r\n    author = auth,\r\n    author_email = auth_email,\r\n    executables = [Executable(filename)]\r\n    )\r\n"
  },
  {
    "path": "randomModule.py",
    "content": "import random\r\n\r\n\r\ninside = random.randint(1,37890) # choses a random integer between given range\r\nprint(inside)\r\n\r\noutside = random.randrange(1,1000) # choses a random number number in given range\r\nprint(outside)\r\n\r\ncolors = ['green','black','blue','yellow','white'] \r\nprint(random.choice(colors))  # choses random element from list\r\n"
  },
  {
    "path": "readFiles.py",
    "content": "# Reading files\r\n\r\n# Enter file name which is in same directory as that of the program\r\nfileName = str(input('File name : ')) \r\nfileToRead = open(fileName, 'r') # 'r' reads the file\r\nprint(fileToRead.read()) # reading file\r\nfileToRead.close() # closing the file\r\n"
  },
  {
    "path": "reverse_sort.py",
    "content": "\"\"\"\r\nThis sort is designed by me.\r\nFirst self designed sorting Algorithm.\r\nKalpak Take\r\n\"\"\"\r\n\r\ndef reverse_sort(array):\r\n\tfor i in range(len(array) - 1):\r\n\t\tfor n in range(len(array) - 1):\r\n\t\t\ta = array[n]\r\n\t\t\tif (a < array[i]):\r\n\t\t\t\ttem = array[i]\r\n\t\t\t\tarray[i] = a \r\n\t\t\t\tarray[n] = tem \r\n\treturn array\t\t\t\r\n\t\r\nprint reverse_sort([123, 3455, 6577, 546, 345, 22, 56, 7])\t\r\n"
  },
  {
    "path": "rock,paper,scissor.py",
    "content": "import random\r\nwhile 2 == 2:\r\n    print('--------------------------------------------------------------')\r\n    get_again = raw_input('Enter rock paper or scissor :  ')\r\n    make_use = random.choice(['rock','paper','scissor'])\r\n    print('--------------------------------------------------------------')\r\n    print(make_use)\r\n    print('--------------------------------------------------------------')\r\n    if get_again == 'rock' and make_use == 'paper':\r\n        print('computer wins! You \"LOSE\" ')\r\n        print('--------------------------------------------------------------')\r\n        continue\r\n    elif get_again == 'rock' and make_use == 'scissor':\r\n        print('computer loses You win!')\r\n        print('--------------------------------------------------------------')\r\n        break\r\n    elif get_again == 'rock' and make_use == 'rock':\r\n        print('It\\'s a tie ! try again !')\r\n        print('--------------------------------------------------------------')\r\n        continue\r\n    elif get_again == 'paper' and make_use == 'paper':\r\n        print('It\\'s a tie ! try again !')\r\n        print('--------------------------------------------------------------')\r\n        continue\r\n    elif get_again == 'scissor' and make_use == 'scissor':\r\n        print('It\\'s a tie ! try again !')\r\n        print('--------------------------------------------------------------')\r\n        continue\r\n    elif get_again == 'paper' and make_use == 'scissor':\r\n        print('computer wins! You \"LOSE\" ')\r\n        print('--------------------------------------------------------------')\r\n        continue\r\n    elif get_again == 'scissor' and make_use == 'paper':\r\n        print('computer loses You win!')\r\n        print('--------------------------------------------------------------')\r\n        break\r\n    elif get_again == 'paper' and make_use == 'rock':\r\n        print('computer wins! You \"LOSE\" ')\r\n        print('--------------------------------------------------------------')\r\n        continue\r\n    elif get_again == 'scissor' and make_use == 'rock':\r\n        print('computer wins You \"LOSE\" ')\r\n        print('--------------------------------------------------------------')\r\n        continue\r\n    else :\r\n        print('Invalid input: Try again')\r\n        continue\r\n\r\n    \r\n"
  },
  {
    "path": "selection_sort.py",
    "content": "#Selection Sort\ndef selection_sort(l):\n\t# Scan slices l[0:len(l)], l[1:len(l)], …\n\tfor start in range(len(l)):\n\t# Find minimum value in slice . . .\n\t\tminpos = start\n\t\tfor i in range(start,len(l)):\n\t\t\tif l[i] < l[minpos]:\n\t\t\t\tminpos = i\n\t\t\t\t# . . . and move it to start of slice\n\t\t(l[start],l[minpos]) = (l[minpos],l[start])\n\treturn(l)\t\n\t\t\n# Test\nresult = selection_sort([9,8,7,6,5,4,3,2,1])\nprint(\"Builtin Method Result: {}\".format(sorted([9,8,7,6,5,4,3,2,1])))\nprint(\"Selection Sort Method Result: {}\".format(result))\n"
  },
  {
    "path": "sendingEmailsInPython.py",
    "content": "import smtplib\r\n\r\n# REMEMBER : dont send mails through public computers or servers \r\n\r\n# connecting to googles serevrs\r\nserverToLogin = smtplib.SMTP('smtp.gmail.com' , 587)\r\n# Username\r\nuserName = str(input('Username for Gmail : '))\r\n# password\r\npassword = str(input('Password Of Account : '))\r\n# Logging in \r\nserverToLogin.login(userName , password)\r\n\r\ndef sendMail():\r\n\tyourEmail = str(input('Your Email Address : ')) # senders email address\r\n\ttoSendEmail = str(input('Receivers Email Address')) # receivers email address\r\n\tmessageHead = str(input('Message Head : ')) # Message head\r\n\tmessageBody = str(input('Message : ')) # main message\r\n\tfullMessage = messageHead + '\\n' + messageBody # full message\r\n\tserverToLogin.sendmail(yourEmail , toSendEmail , fullMessage)  # sending email address through server \r\n\r\nwhile True:\r\n\ttoSendOrNot = str(input('Send or End : '))\r\n\tif toSendOrNot == 'Send':\r\n\t\tprint('\\n')\r\n\t\tprint(sendMail())\r\n\telse :\r\n\t\tquit()\r\n\r\n\r\n\r\n\r\n"
  },
  {
    "path": "server_file.py",
    "content": "import socket\r\nserver_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)\r\nhost = socket.gethostbyname(socket.gethostname())\r\nport = 12345\r\nserver_socket.bind((host,port))\r\nprint(\"Server socket sucessfully Created on IP : {} at port {} \".format(host,port))\r\nserver_socket.listen()\r\nprint(\"Server is waiting for clients to connect .... \\n\\n\")\r\nclient_socket,client_addr = server_socket.accept()\r\nprint(\"Client is connected\")\r\nprint(\"Client's IP {}:{}\\n\\n\".format(*client_addr))\r\nf = open(input(\"Enter path to your file \"),'rb')\r\nname =f.name\r\nclient_socket.send(name.encode())\r\nfor line in f:    \r\n    client_socket.send(line)\r\nelse :\r\n    client_socket.send(\"EOF\".encode()) \r\n    client_socket.close()\r\n    server_socket.close()\r\n\r\n\r\n"
  },
  {
    "path": "shell_games/README.md",
    "content": "\n<pre> \n<i>'shell_games'</i> Sub-directory contains all the <strong>games(programs)</strong>\nwritten for terminal/shell/command line.\nMore games like <i>sudoku, chess, battleship, et cetera</i> are on their way!\n</pre>\nThe programs have been <strong>re-checked</strong> and <strong>re-mastered</strong> by me!<br>\nAlthough i've tried to keep it as orignal as possible.<br>\nKeep Patience It'll take time to go through every program!!<br>\n<b>Thanks</b>\n\n"
  },
  {
    "path": "shell_games/battleship.py",
    "content": "# Add Encoding and path to exec \r\n\r\n\r\nfrom random import randint\r\nimport sys\r\n\r\n\r\nclass BattleShip:\r\n\tdef __init__(self, rows_grid, columns_grid, co_ord_symbol):\r\n\t\t# Initializes battleship board of n * m size\r\n\t\tself.board = self.create_board(rows_grid, columns_grid, co_ord_symbol)\r\n\t\t\r\n\t\t# Placing ship randomly on board x refers to \r\n\t\t# array, y refers to index in array\r\n\t\tself.ship_x = randint(0, rows_grid)\r\n\t\tself.ship_y = randint(0, columns_grid)\r\n\r\n\r\n\tdef create_board(self, x_length, y_length, co_ord_symbol=\"o \"):\r\n\t\t# creates a multi-dimensional array of \r\n\t\t# n * m length\r\n\t\treturn [[co_ord_symbol]*x_length for col in range(y_length)]\r\n\r\n\r\n\tdef view(self):\r\n\t\t# For graphical representation of board\r\n\t\tfor row in self.board:\r\n\t\t\tprint(\" \".join(row))\r\n\r\n\r\n\tdef is_ship_there(self, x_cord_guess, y_cord_guess):\r\n\t\t# Check if ship exists at given co-ordinates\r\n\t\tif self.ship_x == x_cord_guess and self.ship_y == y_cord_guess:\r\n\t\t\treturn True\r\n\r\n\t\treturn False\r\n\r\n\r\n\tdef no_place_for_old_guess(self, row, col):\r\n\t\t# Replaces the co-ordinate at wrong guessed\r\n\t\t# ship position for convinience with X\r\n\t\tself.board[row][col] = \"X \"\r\n\r\n\r\n\tdef get(self, row, col):\r\n\t\t# For UI purpose see ln 72\r\n\t\treturn self.board[row][col]\r\n\r\n\r\ndef battleshipUI():\r\n\t# Maximum n turns for player to guess the position of ship\r\n\tmax_turns = 5\r\n\tturns = 0\r\n\r\n\r\n\t# Board of rows * columns for playing\r\n\trows = int(input(\"How many rows? \"))\r\n\tcols = int(input(\"How many columns? \"))\r\n\tlets_battle = BattleShip(rows, cols, \"o \")\r\n\r\n\t\r\n\t# Execute until user runs out of chances\r\n\twhile turns < max_turns:\r\n\t\t# View the board at each new chance\r\n\t\tprint(\"\\n\\nOcean:\")\r\n\t\tlets_battle.view()\r\n\r\n\r\n\t\t# User to guess position of ship\r\n\t\trow_guess = int(input(\"\\nGuess row? \"))\r\n\t\tcol_guess = int(input(\"Guess column? \"))\r\n\r\n\r\n\t\t# Conditions if user guessed correctly,\r\n\t\t# or missed it or guessed extremely wrong\r\n\t\t# co-ordinates\r\n\t\tif lets_battle.is_ship_there(row_guess, col_guess):\r\n\t\t\tprint(\"\\n  > Damn! You sunk my SHIP!\")\r\n\t\t\tprint(\"  > You Won the Game!\\n\\nSee You Soon!\")\r\n\t\t\tsys.exit(0)\r\n\t\t\r\n\t\telif (row_guess >= rows or row_guess < 0 or col_guess >= cols or col_guess < 0):\r\n\t\t\tprint(\"\\n - Ship isn't even in Ocean!\")\r\n\t\t\r\n\t\telse:\r\n\t\t\tif lets_battle.get(row_guess, row_guess) == \"X \":\r\n\t\t\t\tprint(\"\\n - Really you tried that already!\")\r\n\t\t\telse:\r\n\t\t\t\tprint(\"\\n - Wrong Guess! Use your sailor's instincts!\")\r\n\t\t\t\r\n\t\t\t# Replace symbol o with X to tell user \r\n\t\t\t# He/She already tried those co-ordinates\r\n\t\t\tlets_battle.no_place_for_old_guess(row_guess, col_guess)\r\n\r\n\t\tturns += 1\r\n\r\n\tprint(\"\\n~~~GAMEOVER~~~\")\r\n\r\n\r\nbattleshipUI()\r\n"
  },
  {
    "path": "shell_games/battleship_info.txt",
    "content": "\n\nBattleship:\n  Computer places a ship on the board\n  User/Player has to guess the position os ship\n  \n  Rows and columns are numbered from 0 to n-1\n  and not 1 to n\n  \n  Structure of code can be understood by giving a careful look!\n  You'll notice the game is highly customizable!\n  Enjoy the game!\n"
  },
  {
    "path": "shell_games/dice_rolling_simulator.py",
    "content": "# Add encoding and path to executable\r\n\r\n\r\nimport sys\r\nimport time\r\nimport random\r\n\r\n\r\nclass DiceRollSim:\r\n\tdef __init__(self, no_of_players, no_of_dies):\r\n\t\tself.players = self.assign_names(no_of_players)\r\n\t\tself.die_n = no_of_dies\r\n\r\n\tdef assign_names(self, n):\r\n\t\t# Assigns names to 'n' players playing\r\n\t\tdict_players = {}\r\n\r\n\t\t# All members are indentified by name\r\n\t\t# and not number\r\n\t\tfor i in range(n):\r\n\t\t\tdict_players[i + 1] = str(\r\n\t\t\t    input(\"Name for player({}): \".format(i + 1)))\r\n\t\t\r\n\t\treturn dict_players\r\n\r\n\tdef roll_die(self):\r\n\t\t# Roll die n number of times \r\n\t\t# In case playing with multiple dies\r\n\t\treturn [random.randint(1, 6) for roll in range(self.die_n)]\r\n\r\n\tdef play(self):\r\n\t\t# Main\r\n\t\trounds = 0\r\n\t\twhile True:\r\n\t\t\t# Continue playing until desired\r\n\t\t\tif str(input(\"\\n\\n[+]Continue [Y/n]? \")).strip().lower() == \"y\":\r\n\t\t\t\tprint(\"\\nRound-> %d\" % rounds)\r\n\r\n\t\t\t\t# Print rolled die upper face number/s\r\n\t\t\t\t# for each player playing, along with sum for quick moves\r\n\t\t\t\tfor player_num in self.players.keys():\r\n\t\t\t\t\trolled = self.roll_die()\r\n\t\t\t\t\tprint(\"  > Chance of player %s:  %s  total: %d\" %\r\n\t\t\t\t\t      (self.players[player_num], rolled, sum(rolled)))\r\n\r\n\t\t\t\t\t# Delay for better user experience\r\n\t\t\t\t\ttime.sleep(5)\r\n\r\n\t\t\t\t# Update rounds played\r\n\t\t\t\trounds += 1\r\n\t\t\t\tcontinue\r\n\t\t\telse:\r\n\t\t\t\t# Finished playing\r\n\t\t\t\tprint(\"\\n > Rounds played: %d\" % rounds)\r\n\t\t\t\tbreak\r\n\r\n\r\ndef main_interface():\r\n\t# Indroductions\r\n\tprint(\" \" * 7 + \"| Dice Rolling Simulator | \\n\\n\")\r\n\r\n\t# Initializations/Declarations\r\n\tplayers_n = abs(int(input(\"> How many players?  \")))\r\n\tdie_n = abs(int(input(\"> Number of dies?  \")))\r\n\tprint(\"\\n\\n\")\r\n\tdie_rolling_simulator = DiceRollSim(players_n, die_n)\r\n\r\n\tprint(\"\\nNumber of players playing -> %d\\nWith %d dies.\" % (players_n, die_n))\r\n\t# And the game begins\r\n\tdie_rolling_simulator.play()\r\n\r\n\tprint(\"\\n\\nSee you at another game!\")\r\n\tsys.exit(0)\r\n\r\n\r\nmain_interface()\r\n"
  },
  {
    "path": "shell_games/dice_rolling_simulator_info.txt",
    "content": "\n\n\nDiceRollingSimulator:\n      Basically simulates rolling of die for 'n' players\n      Playing with given number of dies\n      Each player is identified by name\n      During each dice rolling session, session is called as round\n      After each round user can either continue playing another round\n      Or simply exit\n\n      Simulator is helpful in playing all board games played with dies\n"
  },
  {
    "path": "shell_games/number_guessing_game.py",
    "content": "#!/usr/bin/python3\r\nfrom random import randint\r\n\r\nMAX_ = 500 # Specify biggest possible value from random number generation\r\n\r\n# Asks user for a guess and returns this when successful\r\ndef get_guess():\r\n\twhile True:                                         # Run forever, until broken\r\n\t\ttry:                                            # Try the following, if fails, run the except statment\r\n\t\t\tuser_input = int(input(\"Guess a number: \")) # Get user input and covert it to an int (number)\r\n\t\t\tbreak                                       # If the input can be converted, break the loop\r\n\t\texcept ValueError:                              # This runs if the input could not be converted - text was entered\r\n\t\t\tprint(\"Enter a number!\\n\")                  # Tell them to enter a number, then run loop again\r\n\treturn user_input                                   # Return value when loop broken\r\n\r\nnum_to_guess = randint(0, MAX_) # Generates a random number between 0 and value of MAX_\r\nprint(\"Welcome to my random number guessing game!\\nGuess a number between 0 and \", MAX_, \"\\n\")\r\n\r\nwhile True:\r\n\tguess = get_guess()\r\n\tif guess >= 0 and guess <= MAX_: # Check if guess between 0 and max\r\n\r\n\t\t# Correct number!\r\n\t\tif guess == num_to_guess:\r\n\t\t\tprint(\"That's a correct guess!\\nYou got it!\\n\")\r\n\t\t\tbreak\r\n\r\n\t\t# Incorrect - give hint\r\n\t\telif guess < num_to_guess:\r\n\t\t\tprint(\"Try a bigger num!\")  # Number to small\r\n\t\telse:\r\n\t\t\tprint(\"Try a smaller num!\") # Number to big\r\n\r\n\t# Number is not in range\r\n\telse:\r\n\t\tprint(\"Enter a number in between 0 and \", MAX_) \r\n\t\r\n\tprint(\"\")\r\n\r\n'''\r\n\r\n*Challenge*\r\n\r\n\t 1) Can you give the user the option to Play Again? \r\n\t  - if yes, the game will reset - including the random number\r\n\r\n\t 2) Try count the number of guesses and give a score to the user when they guess the number \r\n\t  - the lower the guesses, the higher the score\r\n\r\n'''\r\n"
  },
  {
    "path": "simple_scripts/ListExample.py",
    "content": "my_list = ['p','y','t','h','o','n']\r\n# Output: p\r\nprint(my_list[0])\r\n\r\n# Output: t\r\nprint(my_list[2])\r\n\r\n# Output: o\r\nprint(my_list[4])\r\n\r\n# Error! Only integer can be used for indexing\r\n# my_list[4.0]\r\n\r\n# Nested List\r\nn_list = [\"Happy\", [2,0,1,5]]\r\n\r\n# Nested indexing\r\n\r\n# Output: a\r\nprint(n_list[0][1])    \r\n\r\n# Output: 5\r\nprint(n_list[1][3])\r\n"
  },
  {
    "path": "simple_scripts/README.md",
    "content": "\n<pre> \n<i>'simple_scripts'</i> Sub-directory contains all simplest programs,\nthese programs are <strong>simple to read/write</strong>.\n</pre>\nThe programs have been <strong>re-checked</strong> and <strong> improved a bit </strong> <br/>\nAlthough i've tried to keep it as orignal as possible. <br/>\n<b>Thanks</b>\n"
  },
  {
    "path": "simple_scripts/args_example.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\n# *args is used when we don't know the exact number of \r\n# arguments are going that will be passed, so this placeholder\r\n# is used commonly\r\n\r\ndef add_numbers(*args):\r\n    res = 0\r\n    for i in args:\r\n        res += i\r\n    return res\r\n\r\n# Quick Test\r\nt1 = add_numbers(123,435,876,12,54,76,78954,89,87,56,78,98,56,32,87)\r\nif t1 == sum([123,435,876,12,54,76,78954,89,87,56,78,98,56,32,87]):\r\n    print(\"Sum: \" + str(t1))\r\nelse:\r\n    print(\"Something went wrong!\")\r\n\r\n"
  },
  {
    "path": "simple_scripts/args_example_1.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\n# *params is just a placeholder(try putting other name) \r\n# for n number of arguments\r\n# so that n can be any number, instead of params\r\n# any name can be used, but the * asterisk is important\r\n\r\n# Below function, is a generator\r\n# generates a tuple containing arg, and a boolean value\r\n# every time it encounters argument\r\ndef squared(*params):\r\n    for arg in params:\r\n        yield((arg, arg % 2 == 0))\r\n\r\n# Quick Test\r\nprint(\"Divisibility Test(by 2): \")\r\nfor n, bool_ in squared(12, 13, 34, 4576, 234536, 2341):\r\n    if bool_:\r\n        print(\"  [\" + str(n) + \"] -> is divisible by 2!\")\r\n    else:\r\n        print(\"  [\" + str(n) + \"] -> is NOT divisible by 2!\")\r\n"
  },
  {
    "path": "simple_scripts/class_animal_attributes_examples.py",
    "content": "class Animal:\n    def __init__(self, species, name, legs, color, voices):\n        self.species = species\n        self.name = name\n        self.legs = legs\n        self.color = color\n        self.voices = voices\n\ncat = Animal(\"Cat\" , \"Pussy-Cat\" ,  4 ,  \"white\" , \"meow\")\ndog = Animal(\"Dog\" , \"Cloudy\",  4 , \"brownie\" , \"bark\")\n\nprint(\"Species of animal : \",dog.species)\nprint(\"name of animal : \",dog.name)\nprint(\"no. of legs       : \",dog.legs)\nprint(\"color of animal : \",dog.color)\nprint(\"voice of animal : \",dog.voices)\nprint(\"  \")\nprint(\"Species of animal : \",cat.species)\nprint(\"name of animal : \",cat.name)\nprint(\"no. of legs        : \",cat.legs)\nprint(\"color of animal : \",cat.color)\nprint(\"voice of animal : \",cat.voices)\n"
  },
  {
    "path": "simple_scripts/class_example_movies.py",
    "content": "class movie():\r\n\tdef __init__(self, name, rating, director, budget, description):\r\n\t\tself.name = name\r\n\t\tself.rating = rating\r\n\t\tself.director = director\r\n\t\tself.budget = budget\r\n\t\tself.description = description\r\n\r\n\tdef good_movie(self):\r\n\t\tif self.rating >= 4:\r\n\t\t\treturn(\"It's a good movie.\")\r\n\r\n\r\ntoy_story = movie(\"ToyStory2\" , 4 , \"John Lasseter , Lee Unkrich , Ash Brannon\" , \"90 millon USD\" , \"\"\"When Woody is toy-napped by a greedy toy collector and is nowhere to be found, Buzz and his friends set out to rescue him.But Woody too is tempted by the idea of becoming immortal in a museum.\r\n\"\"\")\t\t\t\t\r\n\r\nprint(\"Title : \" + str(toy_story.name))\r\nprint(\"Rating : \" + str(toy_story.rating))\r\nprint(\"Director : \" + str(toy_story.director))\r\nprint(\"Budget : \" + str(toy_story.budget) + \"\\n\")\r\nprint(\"Description :  \" + str(toy_story.description))\r\nprint(toy_story.good_movie())\r\n"
  },
  {
    "path": "simple_scripts/class_movies.py",
    "content": "class Movie:\r\n\tdef __init__(self, name, rating, director, budget, description):\r\n\t\tself.name = name\r\n\t\tself.rating = rating\r\n\t\tself.director = director\r\n\t\tself.budget = budget\r\n\t\tself.description = description\r\n\r\n\tdef good_movie(self):\r\n\t\tif self.rating >= 4:\r\n\t\t\treturn\"Good Movie\"\r\n\t\telse:\r\n\t\t\treturn \"Average Movie\"\r\n\r\n\r\ntoy_story = Movie(\"ToyStory2\" , 4 , \"John Lasseter , Lee Unkrich , Ash Brannon\" , \"90 millon USD\" , \"When Woody is toy-napped by a greedy toy collector and is nowhere to be found, \\nBuzz and his friends set out to rescue him.\\nBut Woody too is tempted by the idea of becoming immortal in a museum.\")\t\t\t\t\r\n\r\nprint(\"Title : \" + toy_story.name)\r\nprint(\"Rating : \" + str(toy_story.rating))\r\nprint(\"Director : \" + toy_story.director)\r\nprint(\"Budget : \" + str(toy_story.budget))\r\nprint(\"Description :  \" + toy_story.description)\r\nprint(\"Comment: \" + toy_story.good_movie())\r\n"
  },
  {
    "path": "simple_scripts/conditionals_examples.py",
    "content": "# THIS SCRIPT IS TO UNDERSTAND\r\n# THAN TO EXECUTE!\r\n\r\n# Conditionals Examples\r\n# if , elif , else \r\n\r\n# Condition Testing operators\r\n# == checks equality\r\n# != not equal to \r\n# > greater than\r\n# < less than\r\n# <= smaller than equal to\r\n# >= greater than equal to\r\n\r\n# Let's start with if \r\n# Let's say we have a robot and we want it to move forward by 20 steps\r\nrobotMoving = True\r\nif robotMoving == True:\r\n\tprint('Move 20 steps')\r\n\r\n# Okay what about if robot is not moving\r\n# This is where else : statement comes in \r\nrobotMoving = False\r\nelse :\r\n\tprint('You are not moving')\t\r\n\r\n# elif \r\n# What if there are multiple things to check like if\r\n# We need more if statements but each if will run\r\n# Thus we need elif(else if) statement \r\n# Only else : statements dont contain values to check\r\nstart = str(input('Enter a or b or c : '))\r\n# we need to check if entered value is equal to a or b or c\r\nif start == 'a':\r\n\tprint('You entered ' + start)\r\nelif start == 'b':\r\n\tprint('You entered ' + start)\r\nelif start == 'c':\r\n\tprint('You entered ' + start)\t\r\nelse:\r\n\tprint('Invalid Input')\r\n\r\n# Another Example\r\nnumsA = input('Enter a : ')\r\nnumsB = input('Enter b : ')\r\nif numsA > numsB:\r\n\tprint(str(numsA) + ' is greater than ' + str(numsB))\r\nelif numsA < numsB:\t\r\n\tprint(str(numsB) + ' is greater than ' + str(numsA))\r\nelse : \r\n\tprint('Numbers are equal')\t\r\n\r\n# nested if else\r\n# You can nest conditionals inside other conditionals\r\nstartProgram = True\r\nnumsA = input('Enter a : ')\r\nnumsB = input('Enter b : ')\r\nif startProgram == True:\r\n\tif numsA > numsB:\r\n\t\tprint(str(numsA) + ' is greater than ' + str(numsB))\r\n\telif numsA < numsB:\t\r\n\t\tprint(str(numsB) + ' is greater than ' + str(numsA))\r\n\telse : \r\n\t\tprint('Numbers are equal')\r\nelse:\r\n\tprint('Can\\'t access program')\t\r\n\r\n#  and or not are helpful\r\n# and returns True if both conditions are true\r\n# or returns True if one of both condition is true\t\r\n# not returns True if condition is false and False if condition is True\r\n\r\n# Think you have bike and you want to go out on a ride but you have to check if you have enough fuel\r\n# remember not evaluates first then and then or \r\n# and \r\nyouHaveBike = True\r\nfuel = 30 \r\nif youHaveBike == True and  fuel > 65:\r\n\tprint('You are good to go')\r\nelse:\r\n\tprint('You need to refill fuel')\r\n\r\n# or\r\nextraFuel = True\r\nif extraFuel = True or  fuel > 65:\r\n\tprint('You are good to go')\r\nelse:\r\n\tprint('You need to refill fuel')\r\n\r\n# not\r\nnumber = 12\r\nif not(number != 11):\r\n\tprint('True')\r\nelse:\r\n\tprint('False')\r\n"
  },
  {
    "path": "simple_scripts/for_loop_fibonnaci",
    "content": "#printing fibonnaci series till nth element\ndef print_fibonacci(n):\n    current_no = 1\n    prev_no = 0\n    for i in range(n):\n        print(current_no, end = \" \")\n        prev_no,current_no = current_no, current_no + prev_no\n\nprint_fibonacci(10)\n"
  },
  {
    "path": "simple_scripts/for_loop_mountain.py",
    "content": "\r\n# Accept User Input, consider (4)\r\nn = int(raw_input(\"How big? \"))\r\n\r\n# Building block of our mountain of money\r\ns = '$'\r\n\r\n# Process for constructing mountain\r\n# Since n = 4,\r\n# range (1, n+1) would be all the integers from 1 to 4 including 1 and 4\r\n# Mountain formed would be:\r\n#    $    i = 1,   ' ' * n-i = 4-1 = 3  is empty space taken 3 times,    s*i is '$' taken once(i times)\r\n#   $$    i = 2,   ' ' * n-i = 4-2 = 2  ,  s*i is '$' taken twice(i times)\r\n#  $$$    and so on\r\n# $$$$\r\n# Again, notice how i and n change for each iteration\r\nfor i in range( 1 , n+1):\r\n    print (' ' *(n-i) + s*i)\r\n\r\n\r\nprint(\"\\n\")  \r\n\r\n\r\n# Other variant\r\ns = '$$'\r\nfor i in range( 1 , n+1):\r\n    print (' ' *(n-i) + s*i)\r\n"
  },
  {
    "path": "simple_scripts/personality_teller.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Personality Teller\nimport random\n\n# Chooses personality randomly\n# Just for fun!\n# Don't be serious!\n\npersonalities = ['Arrogant and Rude','Funny and Polite','Insane and Crazy'\n,'Lover and Cute','Nerd and Boring','Cool and Rude','Cute but arrogant','Intelligent and Geek'\n,'Cool and Funny','Idiot and Crazy','Awesome and Crazy','Good and Smart','Cool and Smart',\n'Smart and Geek','Cool and Smart']\n\nwhile True:\n    if raw_input(\"\\nPress(e) to Exit,\\nName?: \").strip() == \"e\":\n        print(\"\\nHope you enjoyed!\")\n        exit(0)\n    else:\n        print(\"  > You are %s\" % random.choice(personalities))\n"
  },
  {
    "path": "simple_scripts/unicode.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n# returns UNICODE value of a character\r\ndef get_ascii(S):\r\n\t# even if string has only 1 character \r\n\t# it yields same for all\r\n\tif len(S) > 0:\r\n\t\tfor char_ in list(S):\r\n\t\t\tyield((char_, ord(char_)))\r\n\t\r\n\t# ord returns unicode value of given string of length 1\r\n\t# we only increased it's capacity\r\n\t# simple ..eh\r\n\r\n# test\r\ntest_characters = ['A', 'x', 'Y', 'Z', 'm', 'K', \"STack\"]\r\nfor test_case in test_characters:\r\n\tprint(\"Test Case: \" + test_case)\r\n\r\n\tcodes = list(get_ascii(test_case))\r\n\tfor code in codes:\r\n\t\tprint(\"  character: {}, unicode_val: {}\".format(code[0], code[1]))\r\n\tprint(\" \")\r\n"
  },
  {
    "path": "simple_scripts/website_opener.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n# Just Exploring webbrowser lib\r\nfrom webbrowser import open as web_open\r\n\r\n# Simple function to open given link in webbrowser\r\ndef open_website(link):\r\n    try:\r\n        print(\"Opening link: \" + link)\r\n        web_open(link)\r\n    except Exception as e:\r\n        print(\"Error Occurred:\\n {}\".format(e))\r\n    \r\n    \r\n# Just for test\r\nget_link = raw_input(\"Link to open: \")\r\nopen_website(get_link)\r\n"
  },
  {
    "path": "sleepWellAlarm.py",
    "content": "# Alarm in Python\r\n# Playing Sound on youtube to wake the person up\r\n# I havent really battle tested the program so it might contain bugs\r\n# If you come accross the bugs inform me\r\n\r\nfrom time import sleep,ctime\r\nimport datetime\r\nimport webbrowser\r\nimport random\r\n\r\nnow = datetime.datetime.now()\r\nlinksToSounds = ['https://www.youtube.com/watch?v=6pR5cyH63mA','https://www.youtube.com/watch?v=e12KryuLcbs','https://www.youtube.com/watch?v=nbjwmC8K4K4','https://www.youtube.com/watch?v=UqSww10eeKw','https://www.youtube.com/watch?v=9f06QZCVUHg','https://www.youtube.com/watch?v=kffacxfA7G4'] # remember to add links and test the code\r\n\r\ndef alarm(h,m,s):\r\n    timeToSleep = h * 3600 + m * 60 + s\r\n    sleepingTime = sleep(timeToSleep)\r\n    playSound = webbrowser.open_new(random.choice(linksToSounds))\r\n\r\n# Main code\r\nprint(ctime(),'\\n')\r\nstartOrEnd = str(input('Set alarm or End : '))\r\nif startOrEnd.strip() == 'Set alarm':\r\n    hours = int(input('Hours : '))\r\n    minutes = int(input('Minutes : '))\r\n    seconds = int(input('Seconds : '))\r\n    print('Alarm started at %s : %s'%(now.hour,now.minute))\r\n    print(alarm(hours,minutes,seconds))\r\n    wakedUp = False\r\n    while wakedUp == False:\r\n        get = str(input('Have you waked up : '))\r\n        if get == 'Yes':\r\n            print('Good')\r\n            wakedUp = True\r\n        else:\r\n            sleepMoreTime = sleep(300) # playing sound again in 5 minutes\r\n            playSoundAgain = webbrowser.open_new(random.choice(linksToSounds))\r\n            continue\r\n\r\nelse :\r\n    quit()\r\n"
  },
  {
    "path": "snake game/.idea/.gitignore",
    "content": "# Default ignored files\n/shelf/\n/workspace.xml\n"
  },
  {
    "path": "snake game/.idea/inspectionProfiles/profiles_settings.xml",
    "content": "<component name=\"InspectionProjectProfileManager\">\n  <settings>\n    <option name=\"USE_PROJECT_PROFILE\" value=\"false\" />\n    <version value=\"1.0\" />\n  </settings>\n</component>"
  },
  {
    "path": "snake game/.idea/misc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectRootManager\" version=\"2\" project-jdk-name=\"Python 3.10 (snake game)\" project-jdk-type=\"Python SDK\" />\n  <component name=\"PyCharmProfessionalAdvertiser\">\n    <option name=\"shown\" value=\"true\" />\n  </component>\n</project>"
  },
  {
    "path": "snake game/.idea/modules.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectModuleManager\">\n    <modules>\n      <module fileurl=\"file://$PROJECT_DIR$/.idea/snake game.iml\" filepath=\"$PROJECT_DIR$/.idea/snake game.iml\" />\n    </modules>\n  </component>\n</project>"
  },
  {
    "path": "snake game/.idea/snake game.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module type=\"PYTHON_MODULE\" version=\"4\">\n  <component name=\"NewModuleRootManager\">\n    <content url=\"file://$MODULE_DIR$\">\n      <excludeFolder url=\"file://$MODULE_DIR$/venv\" />\n    </content>\n    <orderEntry type=\"inheritedJdk\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n  </component>\n</module>"
  },
  {
    "path": "snake game/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n\n  <body>\n    <h1>Live streaming</h1>\n    <div>\n\n        <img src=\"{{ url_for('video') }}\" width=\"50%\"/>\n    </div>\n\n    </body>\n\n\n</html>\n"
  },
  {
    "path": "snake game/main.py",
    "content": "import math\nimport random\nimport cvzone\nimport cv2\nimport numpy as np\nfrom cvzone.HandTrackingModule import HandDetector\nfrom flask import Flask,render_template,Response\n\napp=Flask(__name__)\ncap = cv2.VideoCapture(0)\ncap.set(3, 1280)\ncap.set(4, 720)\n\ndetector = HandDetector(detectionCon=0.8, maxHands=1)\n\n\nclass SnakeGameClass:\n    def __init__(self, pathFood):\n        self.points = []  # all points of the snake\n        self.lengths = []  # distance between each point\n        self.currentLength = 0  # total length of the snake\n        self.allowedLength = 150  # total allowed Length\n        self.previousHead = 0, 0  # previous head point\n\n        self.imgFood = cv2.imread(pathFood, cv2.IMREAD_UNCHANGED)\n        self.hFood, self.wFood, _ = self.imgFood.shape\n        self.foodPoint = 0, 0\n        self.randomFoodLocation()\n\n        self.score = 0\n        self.gameOver = False\n\n    def randomFoodLocation(self):\n        self.foodPoint = random.randint(100, 1000), random.randint(100, 600)\n\n    def update(self, imgMain, currentHead):\n\n        if self.gameOver:\n            cvzone.putTextRect(imgMain, \"Game Over\", [300, 400],\n                               scale=7, thickness=5, offset=20)\n            cvzone.putTextRect(imgMain, f'Your Score: {self.score}', [300, 550],\n                               scale=7, thickness=5, offset=20)\n        else:\n            px, py = self.previousHead\n            cx, cy = currentHead\n\n            self.points.append([cx, cy])\n            distance = math.hypot(cx - px, cy - py)\n            self.lengths.append(distance)\n            self.currentLength += distance\n            self.previousHead = cx, cy\n\n            # Length Reduction\n            if self.currentLength > self.allowedLength:\n                for i, length in enumerate(self.lengths):\n                    self.currentLength -= length\n                    self.lengths.pop(i)\n                    self.points.pop(i)\n                    if self.currentLength < self.allowedLength:\n                        break\n\n            # Check if snake ate the Food\n            rx, ry = self.foodPoint\n            if rx - self.wFood // 2 < cx < rx + self.wFood // 2 and \\\n                    ry - self.hFood // 2 < cy < ry + self.hFood // 2:\n                self.randomFoodLocation()\n                self.allowedLength += 50\n                self.score += 1\n                print(self.score)\n\n            # Draw Snake\n            if self.points:\n                for i, point in enumerate(self.points):\n                    if i != 0:\n                        cv2.line(imgMain, tuple(self.points[i - 1]), tuple(self.points[i]), (0, 0, 255), 20)\n                cv2.circle(imgMain, tuple(self.points[-1]), 20, (0, 255, 0), cv2.FILLED)\n\n            # Draw Food\n            imgMain = cvzone.overlayPNG(imgMain, self.imgFood,\n                                        (rx - self.wFood // 2, ry - self.hFood // 2))\n\n            cvzone.putTextRect(imgMain, f'Score: {self.score}', [50, 80],\n                               scale=3, thickness=3, offset=10)\n\n            # Check for Collision\n            pts = np.array(self.points[:-2], np.int32)\n            pts = pts.reshape((-1, 1, 2))\n            cv2.polylines(imgMain, [pts], False, (0, 255, 0), 3)\n            minDist = cv2.pointPolygonTest(pts, (cx, cy), True)\n\n            if -1 <= minDist <= 1:\n                print(\"Hit\")\n                self.gameOver = True\n                self.points = []  # all points of the snake\n                self.lengths = []  # distance between each point\n                self.currentLength = 0  # total length of the snake\n                self.allowedLength = 150  # total allowed Length\n                self.previousHead = 0, 0  # previous head point\n                self.randomFoodLocation()\n\n        return imgMain\n\n\ngame = SnakeGameClass(\"donut.png\")\n\ndef game1():\n    while True:\n        success, img = cap.read()\n        img = cv2.flip(img, 1)\n        hands, img = detector.findHands(img, flipType=False)\n\n        if hands:\n            lmList = hands[0]['lmList']\n            pointIndex = lmList[8][0:2]\n            img = game.update(img, pointIndex)\n        cv2.imshow(\"Image\", img)\n        key = cv2.waitKey(1)\n        if key == ord('r'):\n            game.gameOver = False\n        yield (b'--frame\\r\\n'\n               b'Content-Type: image/jpeg\\r\\n\\r\\n' + img+ b'\\r\\n')\n\n@app.route('/')\ndef index():\n    return render_template('index.html')\n\n\n@app.route('/video')\ndef video():\n    return Response(game1())\n\n\nif __name__=='__main__':\n    app.run()"
  },
  {
    "path": "snake_game.py",
    "content": "# Contribution by https://github.com/Karan9034\n\nimport pygame\nimport sys\nimport random\n\nclass Snake(object):\n\tdef __init__(self):\n\t\tself.length=1\n\t\tself.positions=[((SCREEN_WIDTH/2),(SCREEN_HEIGHT/2))]\n\t\tself.direction=random.choice([UP,DOWN,LEFT,RIGHT])\n\t\tself.color=(17,24,47)\n\n\tdef get_head_position(self):\n\t\treturn self.positions[0]\n\n\tdef turn(self,point):\n\t\tif self.length>1 and (point[0] * -1, point[1] * -1) == self.direction:\n\t\t\treturn\n\t\telse:\n\t\t\tself.direction=point\n\n\tdef move(self):\n\t\tcur=self.get_head_position()\n\t\tx,y=self.direction\n\t\tnew=((cur[0] + (x*GRIDSIZE))%SCREEN_WIDTH,(cur[1]+(y*GRIDSIZE))%SCREEN_HEIGHT)\n\t\tif len(self.positions)>2 and new in self.positions[2:]:\n\t\t\tpygame.quit()\n\t\t\tsys.exit()\n\t\telse:\n\t\t\tself.positions.insert(0,new)\n\t\t\tif len(self.positions)>self.length:\n\t\t\t\tself.positions.pop()\n\n\tdef draw(self,surface):\n\t\tfor p in self.positions:\n\t\t\tr=pygame.Rect((p[0],p[1]),(GRIDSIZE,GRIDSIZE))\n\t\t\tpygame.draw.rect(surface,self.color,r)\n\t\t\tpygame.draw.rect(surface,(93,216,228),r,1)\n\n\tdef handle_keys(self):\n\t\tfor event in pygame.event.get():\n\t\t\tif event.type==pygame.QUIT:\n\t\t\t\tpygame.quit()\n\t\t\t\tsys.exit()\n\t\t\telif event.type==pygame.KEYDOWN:\n\t\t\t\tif event.key==pygame.K_UP:\n\t\t\t\t\tself.turn(UP)\n\t\t\t\telif event.key==pygame.K_DOWN:\n\t\t\t\t\tself.turn(DOWN)\n\t\t\t\telif event.key==pygame.K_LEFT:\n\t\t\t\t\tself.turn(LEFT)\n\t\t\t\telif event.key==pygame.K_RIGHT:\n\t\t\t\t\tself.turn(RIGHT)\n\t\t\t\telif event.key==pygame.K_ESCAPE:\n\t\t\t\t\tpygame.quit()\n\t\t\t\t\tsys.exit()\n\nclass Food(object):\n\tdef __init__(self):\n\t\tself.position=(0,0)\n\t\tself.color=(233,163,49)\n\t\tself.randomize_position()\n\n\tdef randomize_position(self):\n\t\tself.position=(random.randint(0,GRID_WIDTH-1)*GRIDSIZE,random.randint(0,GRID_HEIGHT-1)*GRIDSIZE)\n\n\tdef draw(self,surface):\n\t\tr=pygame.Rect((self.position[0],self.position[1]),(GRIDSIZE,GRIDSIZE))\n\t\tpygame.draw.rect(surface,self.color,r)\n\t\tpygame.draw.rect(surface,(93,216,228),r,1)\n\ndef drawGrid(surface):\n\tfor y in range(0,int(GRID_HEIGHT)):\n\t\tfor x in range(0,int(GRID_WIDTH)):\n\t\t\tif (x+y)%2==0:\n\t\t\t\tr=pygame.Rect((x*GRIDSIZE,y*GRIDSIZE),(GRIDSIZE,GRIDSIZE))\n\t\t\t\tpygame.draw.rect(surface,(200,200,200),r)\n\t\t\telse:\n\t\t\t\trr=pygame.Rect((x*GRIDSIZE,y*GRIDSIZE),(GRIDSIZE,GRIDSIZE))\n\t\t\t\tpygame.draw.rect(surface,(100,100,100),rr)\n\nSCREEN_WIDTH=480\nSCREEN_HEIGHT=480\n\nGRIDSIZE=20\nGRID_WIDTH=SCREEN_WIDTH/GRIDSIZE\nGRID_HEIGHT=SCREEN_HEIGHT/GRIDSIZE\n\nUP=(0,-1)\nDOWN=(0,1)\nLEFT=(-1,0)\nRIGHT=(1,0)\n\ndef main():\n\tpygame.init()\n\n\tclock=pygame.time.Clock()\n\tscreen=pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT),0,32)\n\tpygame.display.set_caption(\"Snake\")\n\tsurface=pygame.Surface(screen.get_size())\n\tsurface=surface.convert()\n\tdrawGrid(surface)\n\n\tsnake=Snake()\n\tfood= Food()\n\n\tmyfont=pygame.font.SysFont(\"monospace\",16)\n\n\tscore=0\n\twhile True:\n\t\tclock.tick(10)\n\t\tsnake.handle_keys()\n\t\tdrawGrid(surface)\n\t\tsnake.move()\n\t\tif snake.get_head_position()==food.position:\n\t\t\tsnake.length+=1\n\t\t\tscore+=1\n\t\t\tfood.randomize_position()\n\t\tsnake.draw(surface)\n\t\tfood.draw(surface)\n\t\tscreen.blit(surface,(0,0))\n\t\ttext=myfont.render(\"Score: {0}\".format(score),1,(0,0,0))\n\t\tscreen.blit(text,(5,10))\n\t\tpygame.display.update()\n\nif __name__==\"__main__\":\n\tmain()\n"
  },
  {
    "path": "sortString.py",
    "content": "# function to sort strings\r\ndef sortString():\r\n\tstrr = str(input('Enter : '))\r\n\twords = strr.split()\r\n\twords.sort()\r\n\tprint(' ')\r\n\tfor word in words:\r\n\t\tprint(word)\r\n\r\n# main code\r\nprint('Hello,')\r\nwhile True:\r\n\tstartOrEnd = str(input('Start or End : '))\r\n\tif startOrEnd == 'Start':\r\n\t\tprint(' ')\r\n\t\tprint(sortString())\t\r\n\t\tcontinue\r\n\telif startOrEnd == 'End' :\r\n\t\tprint(' ')\r\n\t\tquit()\t# closes interpreter \r\n\telse :\r\n\t\tprint('Oops Try Again')\r\n\t\tcontinue\t\t"
  },
  {
    "path": "sortingFunctions.py",
    "content": "# functions to sort out data\r\n# they act on lists\r\n# you can apply these functions in your programs\r\n\r\n# this function takes first and second element from list and compare them\r\ndef bubbleSort(g): # g argument is for list\r\n    for x in range(len(g) - 2):\r\n\t    a = g[x]\r\n\t    b = g[x + 1 + 1]\r\n\t    if a > b :\r\n\t\t    return(a)\r\n\t    else :\r\n\t\t    return(b)\r\n# use this to convert output into list\r\n# result = list(map(bubbleSort , g)) replace g with parameter\r\n\r\n# this function checks even num\r\ndef oddSort(odd):# odd can be list or variable\r\n    for x in odd:\r\n        if x % 3 == 0:\r\n    return(x)\r\n# use this to get list as output\r\n# result = list(filter(oddSort , odd)) replace odd with parameter\r\n\r\n# this function checks even num\r\ndef evenSort(eve):# eve can be list or variable\r\n    for a in eve:\r\n        if a % 2 == 0:\r\n    return(a)\r\n# use this to get list as output\r\n# result = list(filter(evenSort , eve)) replace eve with parameter\r\n\r\n# this function checks divisibility\r\ndef divisibleSort(divi , get):# here divi is list and get is an variable set to integer or float\r\n    for r in divi:\r\n        if r % get == 0:\r\n    return(r)\r\n# use this to get output\r\n# result = list(filter(divisibleSort , divi , get)) replace arguments with suitable parameters\r\n\r\n# this function checks if addition of group of two elements has desired answer\r\ndef addBubbleSort(f,user):# here f is list and user is integer or float\r\n    for x in range(len(f) - 2):\r\n        a = f[x]\r\n        b = f[x + 1 + 1]\r\n        if a + b == user:\r\n            return(a,b)\r\n# i havent checked this function check for bugs\r\n# this is how it works\r\n# res = list(filter(addBubbleSort , f , user)) replace arguments with suitable parameters\r\n\r\n# this function checks if subtraction of group of two elements has desired answer\r\ndef subBubbleSort(z,userSub):\r\n    for x in range(len(z) - 2):\r\n        a = z[x]\r\n        b = z[x + 1 + 1]\r\n        if a - b == useSubr:\r\n            return(a,b)\r\n# i havent checked this function check for bugs\r\n#res = list(filter(subBubbleSort , z , userSub)) replace arguments with suitable parameters\r\n"
  },
  {
    "path": "squareTurtle.py",
    "content": "import turtle\r\n\r\ndef square():\r\n    win = turtle.Screen()\r\n    win.bgcolor(\"white\")\r\n    jack = turtle.Turtle()\r\n    for x in range(1,5):\r\n              jack.forward(100)\r\n              jack.right(90)\r\n    win.exitonclick()\r\n       \r\nsquare()      \r\n"
  },
  {
    "path": "square_root_algorithm.py",
    "content": "\"\"\"\tFunction uses prime factorisation method \r\n\tto find square root of number\t\"\"\"\r\n\r\ndef prime_factors(c):\r\n\tpos = 2\r\n\tfactors = []\r\n\twhile (pos <= c):\r\n\t\tif (c % pos == 0):\r\n\t\t\tc = c // pos\r\n\t\t\tfactors.append(pos)\r\n\t\t\tcontinue\r\n\t\telse:\r\n\t\t\tpos = pos + 1\r\n\treturn factors\r\n\r\ndef extract_common(li):\r\n\tfinal = []\r\n\tif (len(li) % 2 != 0):\r\n\t\treturn \"Number is not perfect root.\"\r\n\telse:\r\n\t\tpre = len(li) - 1\r\n\t\tfor n in range(0, pre, 2):\r\n\t\t\ta = li[n]\r\n\t\t\tb = li[n + 1]\r\n\t\t\tif (a == b):\r\n\t\t\t\tfinal.append(b)\r\n\t\t\telse:\t\r\n\t\t\t\treturn \"Number is not perfect root.\"\r\n\treturn final \r\n\r\ndef square_root(take_in):\r\n\tres = 1\r\n\tfor c in take_in:\r\n\t\tres *= c \r\n\treturn res \r\n\r\nget_num = int(raw_input(\"\\nNumber : \"))\t\r\nprint square_root(extract_common(prime_factors(get_num))), \" \""
  },
  {
    "path": "squarecube.py",
    "content": "# pre code\r\n\r\ndef square():\r\n    print(\" \")\r\n    makeUse = raw_input(\"Square or Cube : \")\r\n    if makeUse.strip() == \"Square\":\r\n        print(\" \")\r\n        user = int(raw_input(\"Enter number to get square : \"))\r\n        square = user ** 2\r\n        print(\" \")\r\n        print(\"Square of the number \" + str(user) + \" is \" + str(square))\r\n    elif makeUse.strip() == \"Cube\":\r\n        print(\" \")\r\n        userAgain = int(raw_input(\"Enter number to get square : \"))\r\n        cube = userAgain ** 3\r\n        print(\" \")\r\n        print(\"Cube of the number \" + str(userAgain) + \" is \" + str(cube))\r\n\r\n# main code\r\n\r\nwhile True:\r\n    print(\"Hello,\")\r\n    print(\" \")\r\n    startOrEnd = raw_input(\"Start or End : \")\r\n    print(\" \")\r\n    if startOrEnd.strip() == \"Start\":\r\n        print(square())\r\n    elif startOrEnd.strip() == \"End\":\r\n        print(\" \")\r\n        print(\" \")\r\n        print(\"Program Ended......\")\r\n        break\r\n    else :\r\n        print(\" \")\r\n        print(\"Try Again\")\r\n        continue\r\n    startagain = (\"Start again or End : \")\r\n    print(\" \")\r\n    if startagain.strip() == \"Start again\":\r\n        print(\" \")\r\n        print(\"Starting again.....\")\r\n        continue\r\n    elif startagain == \"End\":\r\n        print(\" \")\r\n        print(\" \")\r\n        break\r\n    else :\r\n        print(\" \")\r\n        print(\"Try Again\")\r\n        continue\r\n"
  },
  {
    "path": "star_turtle.py",
    "content": "Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32\r\nType \"help\", \"copyright\", \"credits\" or \"license()\" for more information.\r\n>>> import turtle\r\n>>> star=turtle.Turtle()\r\n>>> win=turtle.Screen()\r\n>>> win.setworldcoordinates(-100,-100,100,100)\r\n>>> for i in range(5):\r\n\tstar.forward(50)\r\n\tstar.right(144)\r\n\r\n\t\r\n>>> \r\n"
  },
  {
    "path": "stringIndexing.py",
    "content": "# string indexing\r\n\r\n'''\r\nIndexing\r\n0  1  2  3  4\r\nH  E  L  L  O\r\n'''\r\n\r\nmessage = 'Hello'\r\nprint(message[0]) # this will print H that is first letter in the string\r\nprint(message[1:4]) # this will print from index one to index four\r\nprint(message[:3]) # this will print from starting to index 3\r\nprint(message[2:]) # this will print from index 2 till end\r\nprint(message[:]) # this prints whole string\r\nprint(message[0:4:2]) # this escapes 2 characters from string\r\n\r\n# negative Indexing\r\n'''\r\nnegative Indexing\r\n  P  y  t  h  o  n\r\n -6 -5 -4 -3 -2 -1\r\n'''\r\n\r\nawesome = 'Python is awesome'\r\nprint(awesome[:-1]) # -1 prints last character\r\nprint(awesome[-2]) # this prints m from starting\r\nprint(awesome[-7:]) # try this one out in interpreter\r\n\r\nprint('You are ' + awesome[10:] + ' you are learning ' + awesome[:6])\r\n"
  },
  {
    "path": "stringOperations.py",
    "content": "# This example shows you string operations\r\n\r\nname = 'Kalpak'\r\nprint('My name is ' + name) # I have given space after is notice\r\n\r\nage = 14\r\nprint('My age is ', age) # comma seprates two different things you want to print\r\n\r\nprint('This isn\\'t going away too soon.') # that \\ is called as an escape character\r\n# the \\ is used to use same quote in a string\r\n\r\nprint('I love newlines \\n') # \\n prints new line after string or according to its position\r\n\r\nprint('\\t I love tabs') # \\t adds a tab according to its position\r\n\r\nmultiple = 'Iron Man'\r\nprint(multiple * 5) # this will print string 5 times\r\n\r\n# string methods in built\r\ncountry = 'Norway'\r\nprint(country.upper()) # prints all letters in upper case\r\nprint(country.lower()) # prints all letters in lower case\r\nprint(country.title()) # converts into title\r\n\r\n# string formatting\r\nprint('%s %s %s'%('I' , 'am' , 'cool'))\r\n\r\nexpression = 'I love'\r\nmovie = 'Captain America 3'\r\nprint('%s %s'%(expression , movie))\r\n\r\n# type conversion\r\naddition = 12343 + 3349\r\nprint('The answer is ' + str(addition)) # str() method converts non-string into string\r\n"
  },
  {
    "path": "stringReverse.py",
    "content": "# String Reverse\r\n# This program is funny\r\n\r\ngetString = str(input('Word to Reverse : '))\r\nreverseString = getString[::-1] # [::-1] tells to step from end without difference\r\nprint(reverseString)\r\n\r\n\t "
  },
  {
    "path": "sumAverage.py",
    "content": "# average of sum of lists\r\nm = [1,43,656,8,54,,908,4,5,23,78,,435,89,45,476,89]\r\nn = [234,56,90,,675,56,786,90,564,8,657,87,64,354,2,75]\r\nq = [34,76,76,564,34,32,16,67,25,98,90,345,235,64,134,76]\r\n\r\ndef avgSums():\r\n\tsummingUp = sum(m) + sum(n) + sum(q)\r\n\tsummed = summingUp / 3\r\n\treturn(summed)\r\n\r\nprint(avgSums)\t"
  },
  {
    "path": "sum_array.py",
    "content": "def sum_arr(n):\r\n    res = 0\r\n    for x in n:\r\n        res += x\r\n    return res\r\n\r\nnums = [52345,746587,98589,54398,9348,45887,49856]\r\ntest = sum_arr(nums) \r\n\r\n#sum() is Pythons built in method of adding all the elements in a list\r\nif test == sum(nums):\r\n    print(\"Sum of arr: {}\".format(test))\r\nelse:\r\n    print(\"Func dosen't work!\")\r\n# Most simple algorithm ever! Isn't it!\r\n"
  },
  {
    "path": "sum_of_arithmetic_sequence.py",
    "content": "\r\nclass ArithmeticSequence():\r\n\tdef __init__ (self, seq):\r\n\t\tself.seq = seq \r\n\t\t\r\n\tdef sum(self):\r\n\t\tsummed = len(self.seq) / 2 * (self.seq[0] + self.seq[-1])\r\n\t\treturn summed \r\n\r\ntest_sub = [2,4,6,8,10,12,14,16]\t\t\r\nprint(ArithmeticSequence(test_sub).sum())\t\t\r\nprint(sum(test_sub))\r\n"
  },
  {
    "path": "swap_case.py",
    "content": "def swap_case(s):\n    swapped = \"\"\n    for i in range(len(s)):\n        temp = s[i].upper()\n        if (s[i] == temp):\n            swapped += s[i].lower()\n        else:\n            swapped += s[i].upper()\n            \n    return swapped    \n"
  },
  {
    "path": "systemInfo.py",
    "content": "import platform  \r\nimport os  \r\nimport sys\r\n\r\nprint('============================')\r\nprint('System Information : ')\r\nprint(os.name)  \r\nprint(platform.system())  \r\nprint(platform.release(),'\\n')\r\nprint('============================')\r\nprint('Python Version Installed : ')\r\nprint(sys.version,'\\n')\r\nprint('============================')\r\n"
  },
  {
    "path": "table_maker.py",
    "content": "# Tables maker\nnum = int(input(\"Number to make table : \"))\nli_a = [num for num in range(0 , num * 11 , num)]\n \nfor digit in li_a:\n\tprint(digit)\n"
  },
  {
    "path": "take-a-break.py",
    "content": "import webbrowser\r\nimport time\r\n\r\n\r\n\r\nmake_use = 1\r\n\r\nwhile make_use < 3 :\r\n\ttime.sleep(10)\r\n\twebbrowser.open(\"https://www.youtube.com/results?search_query=comedy+pranks\")\r\n\tmake_use = make_use + 1\r\n"
  },
  {
    "path": "testofdivisibility.py",
    "content": "# pre code\r\ndef testDivisibility():\r\n    print(\" \")\r\n    toTest = int(raw_input(\"Enter number of which you want to test Divisibility : \"))\r\n    print(\" \")\r\n    test = int(raw_input(\"Enter number by which you want to test : \"))\r\n    if toTest % test == 0 :\r\n        print(\"-------------Answer---------------- \")\r\n        print(str(toTest) + \" is divisible by \" + str(test))\r\n    else :\r\n        print(str(toTest) + \" is not divisible \" + str(test))\r\n\r\nprint(\" \")\r\nprint(\"--------------------Start-------------------\")\r\nuser = raw_input(\"Start or End : \")\r\n\r\nif user.strip() == \"Start\" :\r\n        print(testDivisibility())\r\n        print(\" \")        \r\n# MAIN code\r\nwhile True:\r\n        get = raw_input(\"Start again or End : \")\r\n        if get.strip() == \"Start again\":\r\n            print(\"---------------Start Again----------------\")\r\n            print(\" \")\r\n            continue\r\n        elif get.strip() == \"End\" :\r\n            print(\" \")\r\n            print(\"------------------Program Ended--------------\")\r\n            print(\" \")\r\n            break\r\n        else :\r\n            break\r\n\r\n    elif user.strip() == \"End\" :\r\n        print(\" \")\r\n        print(\"------------Program Ended-----------\")\r\n        print(\" \")\r\n        break\r\n\r\n    else :\r\n        print(\" \")\r\n        print(\"Invalid Input. Try again\")\r\n        continue\r\n"
  },
  {
    "path": "time_conversion.py",
    "content": "def twelve_to_twenty_four():\r\n\ttime = input().strip()\r\n\tif (time[-2:] == 'PM'):\r\n\t\tif (time[:2] == \"12\"):  return(time[:-2])\r\n\t\telse:  return(str(12 + int(time[:2])) + time[2:-2])\r\n\telse:\r\n\t\tif (time[:2] == \"12\"):  print(\"00\" + time[2:-2])\r\n\t\telse:  return(time[:-2])    \r\n\t\t\r\n# Input Format : 12:00:00AM / 03:12:00PM\t\t\r\nprint(twelve_to_twenty_four())\t\t"
  },
  {
    "path": "tuplesExample.py",
    "content": "# Creating tuples\r\n# Tuples are used to store 2-d grids and fixed values\r\n# tuples are immutable that means they cant be changed\r\n\r\ntupA = () # Empty tuple\r\nprint(tupA)\r\n\r\nc = 12,56,78\r\n\r\ntupC = tuple(c) # tuple() is built-in\r\nprint(tupC)\r\n\r\nx,y,z = (12,45,42)\r\n\r\na = x,y,z\r\nprint(a)\r\nprint(type(a))\r\n\r\n# Accessing items in tuples\r\nprint(tupC[0])\r\nprint(a[1])\r\nprint(tupC[2],'\\n')\r\n\r\n# tuples cant be reassigned\r\n# tupC[1] = 18 # uncomment this line to see the error  this should cause a error 'TypeError'\r\n\r\n# iterating through tuples\r\nfor x in tupC:\r\n\tprint(x)"
  },
  {
    "path": "turtleRandomWeb.py",
    "content": "import random\r\nimport turtle\r\nt = turtle.Pen()\r\n\r\nfor i in range(150):\r\n    t.color(random.choice(['green','red','violet']))\r\n    t.width(5)\r\n    t.forward(i)\r\n    t.right(30)\r\n"
  },
  {
    "path": "useful_scripts/Diffe_Hellman.py",
    "content": "import random, hashlib\r\n\r\ndef list_prime():\r\n    for num in range(3, 1000):\r\n       # all prime numbers are greater than 1\r\n       if num > 1:\r\n           for i in range(2, num):\r\n               if (num % i) == 0:\r\n                   break\r\n           else:\r\n               print(num, end=', ')\r\n\r\ndef is_prime(n):\r\n    \"\"\"if num > 1:\r\n        for i in range(2, num//2):\r\n            if (num % i) == 0:\r\n                return False\r\n                break\r\n        else:\r\n            return True\r\n    else:\r\n        return False\"\"\"\r\n    # Corner cases \r\n    if (n <= 1) : \r\n        return False\r\n    if (n <= 3) : \r\n        return True\r\n  \r\n    # This is checked so that we can skip  \r\n    # middle five numbers in below loop \r\n    if (n % 2 == 0 or n % 3 == 0) : \r\n        return False\r\n  \r\n    i = 5\r\n    while(i * i <= n) : \r\n        if (n % i == 0 or n % (i + 2) == 0) : \r\n            return False\r\n        i = i + 6\r\n  \r\n    return True\r\n\r\ndef cost(h, cost):\r\n    for i in range(cost):\r\n        h = hashlib.sha3_512(h.encode()).hexdigest()\r\n        return h\r\n\r\nprint(\"type 'prime' to choose from list\")\r\nprime = input(\"Enter a largest prime number you can think of >>> \")\r\nif prime == 'prime':\r\n    list_prime()\r\n    prime = int(input(\"Enter a largest prime number you can think of >>> \"))\r\nelse:\r\n    prime = int(prime)\r\n    \r\nif is_prime(prime):\r\n    private = int(input(\"Enter your private key>>> \"))\r\n    public = random.randint(0, 999999999)\r\n    my_share = (public**private)%prime\r\n    my_exchange_key = cost(hashlib.sha3_512(str(my_share).encode()).hexdigest(), 5)\r\n    print()\r\n    print(f\"Your exchange key is --> {my_exchange_key}\")\r\n    print('*' * 100)\r\n\r\n    bob_private = int(input(\"Enter Bob's private key>>> \"))\r\n    bob_share = (public**private)%prime\r\n    bob_exchange_key = cost(hashlib.sha3_512(str(bob_share).encode()).hexdigest(), 5)\r\n    print()\r\n    print(f\"Bob'sexchange key is --> {bob_exchange_key}\")\r\n    print()\r\n    print(f\"my_exchange_key == bob_exchange_key\\n{my_exchange_key == bob_exchange_key}\")\r\n    print('*' * 100)\r\n    \r\nelse:\r\n    print(\"This is not a prime number\")\r\n"
  },
  {
    "path": "useful_scripts/binary_to_decimal_conversion.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\nimport sys\n\n# Binary to decimal conversion\n# See explaination: https://i.imgur.com/heAT0PB.gif   , \n# https://www.electronics-tutorials.ws/binary/bin_2.html\n\ndef binary_to_decimal_conv(binary_string):\n\tres = 0\n\tbinary_l = list(binary_string)\n\tfor bit_i in range(len(binary_l)):\n\t\tres += int(binary_l[bit_i]) * (2 ** bit_i) \n\treturn res \n\n# Test\n# Testing interface\ni = 0\nwhile True:\n\tif raw_input(\"\\n[{}] Exit(press e) or Continue(press c): \".format(i)).strip().lower() == \"c\":\n\t\tprint(\"Decimal form: \" + str(binary_to_decimal_conv(raw_input(\"\\nBinary?: \"))))\n\telse:\n\t\tprint(\"\\nHope you enjoyed!\")\n\t\tsys.exit()\n\ti += 1\n"
  },
  {
    "path": "useful_scripts/bmi_body_mass_index_calculator.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\nimport sys\r\n\r\n# BMI calculator\r\n# f(w, h) = w / h ** 2 \r\n# w refers to weight, h refers to height\r\n# weight is in kilograms(kg's), height in meters(m) standard metrics\r\n\r\nbody_mass_index = lambda w, h: round((w) / ((h  * 0.01) ** 2), 1)\r\n\r\n# Test\r\n# Playing/Testing Interface\r\ni = 0\r\nwhile True:\r\n\tif raw_input(\"\\n[{}] Exit(press e) or To count BMI(press c):\".format(i)).strip().lower() == \"c\":\r\n\t\tcal = body_mass_index(float(raw_input('\\nWeight(in kgs)?: ')), float(raw_input('Height (in cm)?: ')))\r\n\t\t\r\n\t\tprint(\"\\nHealthy BMI ranges between 19 to 25:\")\r\n\t\tprint(\"Status: \")\r\n\t\tif cal >= 19 and cal <= 25:\r\n\t\t\tprint(\"Your BMI: \" + str(cal) + \"\\n  You are HEALTHY\")\r\n\t\telif cal < 19: \r\n\t\t\tprint(\"Your BMI: \" + str(cal) + \"\\n  Your BodyMassIndex is Underweight\\n  Not between Healthy range\")\r\n\t\telse:\r\n\t\t\tprint(\"Your BMI: \" + str(cal) + \"\\n  Your BodyMassIndex is Overweight\\n  Not between Healthy range\")\r\n\t\ti += 1\t\r\n\t\r\n\telse :\r\n\t\tsys.exit()\r\n"
  },
  {
    "path": "useful_scripts/caesars_cipher_encryption.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport string, sys\n\n# Caesar's cipher is type of shift cipher, \n# an encryption technique\n# First used by roman rular Julius Caesar\n# To see how it works refer:\n# web-page/article: https://en.wikipedia.org/wiki/Caesar_cipher OR \n#                   https://www.khanacademy.org/computing/computer-science/cryptography/crypt/v/caesar-cipher\n\n\ndef caesars_cipher_encoding(s, k, lowercase = True, uppercase = False):\n\t\n\t# To encrypt plain text in either \n\t# uppercase letters or lowercase letters\n\tif lowercase:\n\t\talphas = list(string.lowercase)\n\telif uppercase:\n\t\talphas = list(string.uppercase)\n\n\tencrypted = \"\"\n\t# List characters in orignal string\n\tchar_s = list(s)\n\n\t# Shifting of each single \n\t# character in orignal string\n\t# using given key\n\tfor char in char_s:\n\n\t\t# avoid encryption of spaces\n\t\tif char == \" \":\n\t\t\tencrypted += \" \"\n\t\t\n\t\telse:  \n\t\t\t# n_index or new index is\n\t\t\t# the index of encrypted character\n\t\t\tn_index = k + alphas.index(char)\n\t\t\t\n\t\t\t# if encrypted character is greater than\n\t\t\t# length of english alphabets\n\t\t\tif n_index > 25:\n\n\t\t\t\t# Read explaination on line 59\n\t\t\t\twhile not n_index <= 25:\n\t\t\t\t\tn_index = n_index - 26\n\t\t\t\tencrypted += alphas[n_index]\n\t\t\t\n\t\t\t# simple shift\n\t\t\telse:\n\t\t\t\tencrypted += alphas[n_index]\n\t\t\t\t\n\treturn encrypted\n\n# Explaination of key bigger than 26:\n# say we have key 54, \n# we add index of char(say 'a') to key, i.e. key = 54 + 1 = 55\n# so after first iteration over array of length(26), \n# i.e. 55(total iterations to perform) - 26(iterations completed) = 29(iterations left)\n# but, 29 is still a big index i.e. 29 > length of array(26)\n# so we continue to subtract more 26(iterations), \n# i.e. 29(iterations to perform) - (26 iterations done) = 3(remaining)\n# so 3 is smaller than length of array and can be used as key, \n# i.e. 3 < 26(length of array)\n# thus, we reached at index of 3 after 54 iterations over an array of length 26\n# bit complicated but read it twice, you'll master it!\n\n# Test, Playing UI\ni = 0\nwhile True:\n\tif raw_input(\"[{}] Exit(press e), To continue(press c): \".format(i)).lower() == \"c\":\n\t\t# Number of times \n\t\ti += 1\n\n\t\t# Input for String and key for char shift\n\t\tS, K = raw_input(\"\\nString: \"), int(raw_input(\"Key: \"))\n\t\t\n\t\t# Results\n\t\tprint(\"\\nOrignal string: \" + S + \" ,  Key: \" + str(K))\n\t\tprint(\"Encrypted text: \" +  caesars_cipher_encoding(S, K, True, False) + \"\\n\")\n\t\n\telse:\n\t\tsys.exit()\n"
  },
  {
    "path": "useful_scripts/calculator.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\nimport sys\r\n\r\n# Functions to apply basic arithmetic\r\n# operations on 2 numbers \r\n# Each func, takes 2 numbers as input\r\n\r\nadd = lambda a, b: a + b \r\nsubtract = lambda a, b: a - b \r\nmultiply = lambda a, b: a * b \r\ndivide = lambda a, b: a / b \r\nmodulus = lambda a, b: a % b \r\n\r\n# CLI\r\n# Testing/Playing Interface\r\ni = 0\r\nwhile True:\r\n\tif raw_input(\"\\n\\n[{}] Exit(press e) or Calculate(press c): \".format(i)) == \"c\":\r\n\t\top = raw_input(\"\\nAdd(press a), Subtract(press s), Multiply(press m),\\nDivide(press d), Modulus(press mo): \").strip().lower()\r\n\t\tif op == \"a\":\r\n\t\t\tprint(\"  Sum: \" + str(add(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\r\n\t\telif op == \"s\":\r\n\t\t\tprint(\"  Subtracted: \" + str(subtract(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\r\n\t\telif op == \"m\":\r\n\t\t\tprint(\"  Multiplied: \" + str(multiply(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\r\n\t\telif op == \"d\":\r\n\t\t\tprint(\"  Divided: \" + str(divide(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\r\n\t\telse:\r\n\t\t\tprint(\"  Modulus: \" + str(modulus(float(raw_input(\"\\nN1: \")), float(raw_input(\"N2: \")))))\r\n\t\ti += 1\r\n\telse:\r\n\t\tprint(\"\\nHope you enjoyed!\")\r\n\t\tsys.exit()\r\n"
  },
  {
    "path": "useful_scripts/calendar.py",
    "content": "# calender viewer\r\nimport sys\r\nimport calendar\r\n\r\n# function to view calendar\r\nviewCalender = lambda yy, mm: print(\"\\n\\n Calendar > \\n %s\\n\" % calendar.month(yy, mm))\r\n\r\n# UI\r\nwhile True:\r\n\tif str(input(\"[+] Start [Y/n] ?  \")).strip().lower() == \"y\":\r\n\t\ttry:\r\n\t\t\tviewCalender(int(input(\"\\nYear: \")), int(input(\"Month: \")))\r\n\t\texcept IndexError:\r\n\t\t\tprint(\"  -> Try Again! With valid numbers!\\n\")\r\n\telse:\r\n\t\tprint(\"\\nSee Ya Soon!\")\r\n\t\tsys.exit(0)\r\n"
  },
  {
    "path": "useful_scripts/password_generator.py",
    "content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\n# Now-a-days, hashes of our passwords are \n# flowing on internet, but to avoid password\n# getting discovered by whoever got their hands\n# on them, a password should contain:\n#             1. Least 8 characters\n#\t\t\t  2. No words, instead randomly chosen characters\n# \t\t\t  3. Characters i'm refering to are, numbers, \n#\t\t\t\t uppercase/lowercase letters, punctuation's\n# This will protect password against, dictionary/brute force attacks\n\n\nimport random, string, sys\n\n# List of characters, alphabets, numbers\n# to choose from\ndata_set = list(string.ascii_letters) + list(string.digits) + list(string.punctuation)\n\n# generates a random password \n# very strong due to random ness\n# primary protection against dictionary attack on hash tables\n\ndef generate_random_password(n):\n\t# For password to be strong it should\n\t# be at least 8 characters long\n\tif n < 8:\n\t\treturn \"Invalid Input,\\nPassword should be at least 8 characters long!\"\n\t\n\t# Chooses a random character from data_set\n\t# after password of given length is created\n\t# returns it to user\n\tpassword = \"\"\n\tfor x in range(n):\n\t\tpassword += random.choice(data_set)\n\t\n\treturn password \n\n# Test\n\nwhile True:\n\tusr = raw_input(\"Exit(press e), or Length: \").lower()\n\tif usr == \"e\":\n\t\tsys.exit()\n\t\n\tprint(\"Generated password: \" + generate_random_password(int(usr)) + \"\\n\")\n"
  },
  {
    "path": "useful_scripts/pinger.py",
    "content": "import subprocess\r\nfrom datetime import datetime\r\nimport matplotlib.pyplot as plt\r\n\r\npings = []\r\nlosses = []\r\ntimes = []\r\ni = 0\r\n\r\ndef update_line():\r\n    plt.plot(times, pings)\r\n    plt.xticks(rotation=45)\r\n    plt.draw()\r\n\r\n\r\ntry:\r\n    plt.show()\r\n    while True:\r\n        output = subprocess.check_output(\"ping 8.8.8.8\", shell=True)\r\n        losses.append(output.decode().split()[-18])\r\n        output = output.decode().split()[-1]\r\n        time = datetime.now().strftime(\"%H:%M:%S\")\r\n        pings.append(int(output.strip(\"ms\")))\r\n        times.append(time)\r\n        i += 1\r\n        # update_line()\r\nexcept KeyboardInterrupt:\r\n    pings = [int(i) for i in pings]\r\n    losses = [int(i) for i in losses]\r\n    \r\n    plt.figure()\r\n    plt.subplot(211)\r\n    plt.xticks(rotation=45)\r\n    plt.ylabel(\"ping (MS) - avg\")\r\n    plt.plot(times, pings)\r\n\r\n    if sum(losses) != 0:\r\n        plt.subplot(212)\r\n        plt.plot(times, losses)\r\n    \r\n    \r\n    plt.xticks(rotation=45)\r\n    plt.ylabel(\"Loss\")\r\n    plt.show()\r\n    \r\n\r\n\r\n"
  },
  {
    "path": "useful_scripts/timer.py",
    "content": "#!/usr/bin/python\r\n# -*- coding: utf-8 -*-\r\n\r\nimport sys \r\nimport time\r\nimport webbrowser\r\n\r\ndef timer(s, hrs, mins, secs):\r\n    # Convert time into seconds\r\n    _n = secs + mins*60 + hrs*60*60\r\n    \r\n    print(\"\\nTimer Started...\")\r\n    print(\"> Countdown for: %i hours:%i minutes:%i seconds\" %(hrs, mins, secs))\r\n    # This is where real timer works\r\n    # -0.01 is assumed time for execution of above instructions\r\n    time.sleep(_n - 0.01)\r\n    print(\"Time's up!\")\r\n    print(\"...\\...Playing Sound.../...\")\r\n    \r\n    # Play sound after timer count completion\r\n    webbrowser.open(s)\r\n    \r\nwhile True:\r\n    if raw_input(\"\\nContinue[Y/n]? \").strip().lower() == \"y\": \r\n        timer(raw_input(\"\\nSound(Link)?: \").strip(), int(raw_input(\"Hours?: \").strip()), int(raw_input(\"Minutes?: \").strip()), int(raw_input(\"Seconds?: \").strip()))\r\n    else:\r\n        print(\"\\nHope You Enjoyed!\")\r\n        sys.exit(0)\r\n"
  },
  {
    "path": "videodownloader.py",
    "content": "#program ended"
  },
  {
    "path": "writingFiles.py",
    "content": "# Writing files\r\n\r\n# Enter file name which is in same directory as that of the program\r\nfileName = str(input('File name : ')) \r\nfileToWrite = open(fileName, 'w') # 'w' writes to the file\r\ntextToWrite = str(input('Text to write : '))\r\nfileToWrite.write(textToWrite) # writing file\r\nfileToWrite.close() # closing the file\r\n"
  }
]