{"id":189,"date":"2022-02-12T21:52:00","date_gmt":"2022-02-12T21:52:00","guid":{"rendered":"https:\/\/victoria.engineering\/?page_id=189"},"modified":"2024-02-19T23:33:11","modified_gmt":"2024-02-19T23:33:11","slug":"python-basics","status":"publish","type":"page","link":"https:\/\/victoria.engineering\/index.php\/python-basics\/","title":{"rendered":"Python Basics"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.python.org\/\" data-type=\"link\" data-id=\"https:\/\/www.python.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python.org<\/a><\/p>\n\n\n\n<p>Python scripts are stored in *.py files<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>print(&#8220;add text here&#8221;)<\/li>\n\n\n\n<li># to comment out the code<\/li>\n\n\n\n<li>** exponentials<\/li>\n\n\n\n<li>% modulo<\/li>\n<\/ul>\n\n\n\n<p><strong>Variables<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>are case-sensitive<\/li>\n\n\n\n<li>type() to check the type<\/li>\n\n\n\n<li>string &#8211; use &#8221; or &#8216;<\/li>\n\n\n\n<li>float &#8211; real number<\/li>\n\n\n\n<li>int &#8211; integer<\/li>\n\n\n\n<li>boolean &#8211; True or False<\/li>\n\n\n\n<li>= is assignment, not equality<\/li>\n\n\n\n<li>Convert Types\n<ul class=\"wp-block-list\">\n<li>str(), int(), float(), bool()<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Lists<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Used to give a single name to a collection of values<\/li>\n\n\n\n<li>car = [a, b, c]<\/li>\n\n\n\n<li>Can contain mixed data types as well as lists<\/li>\n\n\n\n<li>fam = [[&#8220;Joe&#8221;, 180], [&#8220;Jennifer&#8221;, 135]]<\/li>\n\n\n\n<li>to get information from the list:\n<ul class=\"wp-block-list\">\n<li>fam [2] =&gt; c<\/li>\n\n\n\n<li>fam [-1] =&gt; c &#8211; first item from the end of the list<\/li>\n\n\n\n<li>list [strt : end ] =&gt; list slicing<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Functions<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>help(&lt;add any function name&gt;) &#8211; to get information about a specific function<\/li>\n\n\n\n<li>sorted (iterable, key, reverse) &#8211; key default = None, reverse default = False<\/li>\n<\/ul>\n\n\n\n<p><strong>Methods<\/strong><\/p>\n\n\n\n<p>These are functions that belong to objects: strings, floats, integers, lists, etc.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>index()<\/li>\n\n\n\n<li>count()<\/li>\n\n\n\n<li>append()<\/li>\n\n\n\n<li>remove()<\/li>\n\n\n\n<li>reverse()<\/li>\n\n\n\n<li>upper()<\/li>\n\n\n\n<li>capitalize()<\/li>\n<\/ul>\n\n\n\n<p><strong>Packages<\/strong><\/p>\n\n\n\n<p>Packages are sets of python scripts saved together. Each script represents a module.<\/p>\n\n\n\n<p>To install a package, use pip &#8211; package maintenance systems for Python. Additional information: <a href=\"https:\/\/pip.pypa.io\/en\/stable\/installation\/\">https:\/\/pip.pypa.io\/en\/stable\/installation\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python.org Python scripts are stored in *.py files Variables Lists Functions Methods These are functions that belong to objects: strings, floats, integers, lists, etc. Packages Packages are sets of python scripts saved together. Each script represents a module. To install a package, use pip &#8211; package maintenance systems for Python. Additional information: https:\/\/pip.pypa.io\/en\/stable\/installation\/<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-189","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/victoria.engineering\/index.php\/wp-json\/wp\/v2\/pages\/189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/victoria.engineering\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/victoria.engineering\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/victoria.engineering\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/victoria.engineering\/index.php\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":2,"href":"https:\/\/victoria.engineering\/index.php\/wp-json\/wp\/v2\/pages\/189\/revisions"}],"predecessor-version":[{"id":204,"href":"https:\/\/victoria.engineering\/index.php\/wp-json\/wp\/v2\/pages\/189\/revisions\/204"}],"wp:attachment":[{"href":"https:\/\/victoria.engineering\/index.php\/wp-json\/wp\/v2\/media?parent=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}