[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-689117-105":59,"doc-detail-689117-en":130,"doc-similar-689117":158},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","basic-python-syntax","Basic Python Syntax","","Basic Python Syntax provides a compact overview of core language building blocks through code examples and short explanations. It covers atomic data types such as int, float, bool, and strings, numeric operators, and common string operations like concatenation and indexing. The material then introduces assignments, comparisons, tuple equality, and control flow including for loops with range(), while loops, conditional logic with if/elif/else, and control statements break and continue with loop-specific else behavior. Finally, it demonstrates function definition using def and recursive functions like factorial and Fibonacci.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/basic-python-syntax/689117/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/basic-python-syntax/689117.png","ImageObject",300,407,{"name":92,"@type":93},"WHO AM I","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-18","2026-11-08",true,{"@type":102,"interactionType":103,"userInteractionCount":19},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What basic data types and operators are introduced in this Python syntax overview?","Question",{"text":112,"@type":113},"It lists atomic types including int, float, bool, string, and others, and shows numeric operators such as +, -, *, /, **, and %.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do for loops using range() and while loops differ in the examples?",{"text":117,"@type":113},"The for-loop section uses range() to iterate over sequences, while the while-loop section emphasizes repeated execution under a condition and notes behavioral differences and the need for care.",{"name":119,"@type":110,"acceptedAnswer":120},"What control-flow and function features does the document demonstrate?",{"text":121,"@type":113},"It demonstrates conditional branching with if/elif/else, loop control with break and continue plus loop-level else, and function definitions with def including recursive factorial and Fibonacci.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},689117,1794096795,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":19,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":129,"read_time":144,"preview_page_count":81,"preview_urls":145},10857686687108,"https://eur-avatar.wpscdn.com/avatar/9e0008edd84b319fe0c?x-oss-process=image/resize,m_fixed,w_180,h_180&k=1794290847020028784","Basic Python Syntax  \n\n| Numbers and Strings |\n| --- |\n| • like Java, Python has built-in (atomic) types\u003Cbr>• numbers ( int, float), bool, string, list, etc .\u003Cbr>• numeric operators: + - * / ** %\u003Cbr>>>> a = 5\u003Cbr>>>> b = 3\u003Cbr>>>> type (5)\u003Ctype 'int'>>>> a += 4\u003Cbr>>>> a\u003Cbr>9\u003Cbr>no i++ or ++i\u003Cbr>>>> c = 1.5\u003Cbr>>>> 5/2 2\u003Cbr>>>> 5/2 . 2.5\u003Cbr>>>> 5 ** 2 25\u003Cbr>>>> from __future__ import division >2>>5 5/2 recommended!\u003Cbr>>>> s = “hey”\u003Cbr>>>> s + “ guys”\u003Cbr>'hey guys'>>> len(s) 3 >>> s[0]\u003Cbr>'h'>>> s[-1]'y'\u003Cbr>19 |\n\nAssignments and Comparisons  \n>>> a = b = 0  \n>>> a 0 >>> b 0  \n>>> a, b = 3, 5  \n>>> a + b 8  \n>>> (a, b) = (3, 5)>>> a + b  \n>>> 8  \n>>> a, b = b, a (swap)  \n>>> a = b = 0  \n>>> a == b True  \n>>> type (3 == 5)\u003Ctype 'bool'>>>> \"my\" == 'my'True  \n>>> (1, 2) == (1, 2) True  \n>>> 1, 2 == 1, 2  \n???  \n(1, False, 2)  \n20  \n\n| \u003Cbr>for loops and range()\u003Cbr>• for always iterates through a list or sequence |  |\n| --- | --- |\n| >>> sum = 0\u003Cbr>>>> for i in range(10):\u003Cbr>... sum += i\u003Cbr>... Java 1.5\u003Cbr>>>> print sum foreach (String word : words)\u003Cbr>45 System.out.println(word)\u003Cbr>>>> for word in [\"welcome\", \"to\", \"python\"]:... print word,\u003Cbr>...\u003Cbr>welcome to python\u003Cbr>>>> range(5), range(4,6), range(1,7,2)([0, 1, 2, 3, 4], [4, 5], [1, 3, 5]) | 21 |\n\nwhile loops  \n• very similar to while in Java and C • but be careful  \n• in behaves differently in for and while • break statement, same as in Java/C  \n>>> a, b = 0, 1  \n>>> while b \u003C= 5:  \n... print b  \n... a, b = b, a+b  \n...   \n1 simultaneous  \n1 assignment 2  \n3 ﬁbonacci series 5  \n22  \n\n| Conditionals |  |\n| --- | --- |\n| >>> if x \u003C 10 and x >= 0:\u003Cbr>... print x, \"is a digit\"\u003Cbr>...\u003Cbr>>>> False and False or True\u003Cbr>True >>> not True False | >>> if 4 > 5:\u003Cbr>... print \"foo\"\u003Cbr>... else :\u003Cbr>... print \"bar\"\u003Cbr>...\u003Cbr>bar |\n| >>> print “foo” if 4 > 5 else “bar”\u003Cbr>... conditional expr since Python 2.5\u003Cbr>>>> bar\u003Cbr>C/Java printf( (4>5)? ”foo” : “bar”);\u003Cbr>23 |  |\n\n\n| \u003Cbr>if ... elif ... else |  |\n| --- | --- |\n| \u003Cbr>>>> a = \"foo\"\u003Cbr>>>> if a in [\"blue\", \"yellow\", \"red\"]:\u003Cbr>... print a + \" is a color\"\u003Cbr>... else:\u003Cbr>... if a in [\"US\", \"China\"]:\u003Cbr>... print a + \" is a country\"\u003Cbr>... else :\u003Cbr>... print \"I don't know what”, a, “is!\"\u003Cbr>...\u003Cbr>I don't know what foo is!\u003Cbr>switch (a) {\u003Cbr>>>> if a in ... :\u003Cbr>... print ...\u003Cbr>... elif a in ... :\u003Cbr>... print ...\u003Cbr>... else :\u003Cbr>... print ...\u003Cbr>C/Java\u003Cbr>case “blue”:\u003Cbr>case “yellow”:\u003Cbr>case “red”:\u003Cbr>print . . . ; break; case “US”:\u003Cbr>case “China”:\u003Cbr>print . . . ; break; else :\u003Cbr>print . . . ;} | 24 |\n\n\n| break, continue and else |\n| --- |\n| • break and continue borrowed from C/Java\u003Cbr>• special else in loops\u003Cbr>• when loop terminated normally (i.e., not by break)\u003Cbr>• very handy in testing a set of properties || func(n)\u003Cbr>>>> for n in range(2, 10):\u003Cbr>... for x in range(2, n):\u003Cbr>... if n % x == 0:\u003Cbr>... break\u003Cbr>... else :\u003Cbr>... print n,\u003Cbr>...\u003Cbr>prime numbers\u003Cbr>for (n=2; n\u003C10; n ++) {\u003Cbr>good = true;\u003Cbr>for (x=2; x\u003Cn; x++)\u003Cbr>if (n % x\u003Cbr>C/Java\u003Cbr>}\u003Cbr>good = break;\u003Cbr>if\u003Cbr>if (good)\u003Cbr>== 0) { false;\u003Cbr>(x==n)\u003Cbr>printf(“%d “, n);}\u003Cbr>25 |\n\nDeﬁning a Function def  \n• no type declarations needed! wow!  \n• Python will ﬁgure it out at run-time  \n• you get a run-time error for type violation  \n• well, Python does not have a compile-error at all  \n>>> def fact(n):  \n... if n == 0:  \n... return 1  \n... else:  \n... return n * fact(n-1)  \n...  \n>>> fact(4) 24  \n26  \nFibonacci Revisited  \n>>> a, b = 0, 1  \n>>> while b \u003C= 5:  \n... print b  \n... a, b = b, a+b  \n...  \n1  \n1  \n2  \n3  \n5  \ndef fib(n):  \nif n \u003C= 1:  \nreturn n else :  \nreturn fib (n-1) + fib (n-2)  \nconceptually cleaner, but much slower!  \n>>> fib(5)  \n5  \n>>> fib(6) 8  \n27","cbCais7BKFt3kpfO","https://ap.wps.com/l/cbCais7BKFt3kpfO","pdf",156051,22,"English","# Numbers and Strings\n# Assignments and Comparisons\n# For loops and range()\n# while loops\n# Conditionals\n## if ... elif ... else\n# break, continue and else\n# Defining a Function\n# Fibonacci Revisited","[{\"question\":\"What basic data types and operators are introduced in this Python syntax overview?\",\"answer\":\"It lists atomic types including int, float, bool, string, and others, and shows numeric operators such as +, -, *, /, **, and %.\"},{\"question\":\"How do for loops using range() and while loops differ in the examples?\",\"answer\":\"The for-loop section uses range() to iterate over sequences, while the while-loop section emphasizes repeated execution under a condition and notes behavioral differences and the need for care.\"},{\"question\":\"What control-flow and function features does the document demonstrate?\",\"answer\":\"It demonstrates conditional branching with if/elif/else, loop control with break and continue plus loop-level else, and function definitions with def including recursive factorial and Fibonacci.\"}]","Basic Python Syntax | PDF",55,[146,150,154],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/efed9807165a618c6e4726b9ef115048.webp",983,759,{"page_no":14,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/695619a9e3cd7963ac1cb12dac9d71fe.webp",982,758,{"page_no":81,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/6f7c2e43d9f5fc51a453ea6ca38cccf3.webp",981,757,{"list":159,"token":66},[160,166,172,178,184,191,197,203,209,215],{"doc_id":161,"doc_title":162,"file_type":137,"home_preview_img_url":163,"slug":164,"view_count":19,"category_name":30,"create_tm":165},685664,"General C# Cheat Sheet - Quick reference guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000173279/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=NrjNlJpFJCTSxaWV02XLQ47JUfk%3D","general-c-cheat-sheet-quick-reference-guide",1794016366,{"doc_id":167,"doc_title":168,"file_type":137,"home_preview_img_url":169,"slug":170,"view_count":19,"category_name":30,"create_tm":171},697980,"TUPLES AND DICTIONARIES - Introduction to Tuples","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146829/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=IguPqX%2FBwXJsq0q%2Bqn4bNKjPeW4%3D","tuples-and-dictionaries-introduction-to-tuples",1794446564,{"doc_id":173,"doc_title":174,"file_type":137,"home_preview_img_url":175,"slug":176,"view_count":24,"category_name":30,"create_tm":177},670915,"Python Cheat Sheet - Quick Reference","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988353347/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=QxojVeeNeEz%2FFntOTycjJL%2Bmjj0%3D","python-cheat-sheet-quick-reference-670915",1793572692,{"doc_id":179,"doc_title":180,"file_type":137,"home_preview_img_url":181,"slug":182,"view_count":24,"category_name":30,"create_tm":183},685778,"1-Tuples","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203953/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=glzjV5ZG7FMh%2B5YLzAf9wQPnyeU%3D","1-tuples",1794018230,{"doc_id":185,"doc_title":186,"file_type":137,"home_preview_img_url":187,"slug":188,"view_count":189,"category_name":30,"create_tm":190},347394,"C Programming Language - 2nd Edition (OCR) - Chapter Outline","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229911501529/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=lrZ4zX3agdNf9PoG7xMrysuwTOA%3D","c-programming-language-2nd-edition-ocr-chapter-outline",15,1790066766,{"doc_id":192,"doc_title":193,"file_type":137,"home_preview_img_url":194,"slug":195,"view_count":29,"category_name":30,"create_tm":196},697978,"Lecture 4: Tuples, List Slicing, List Comprehension, Strings","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146771/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=Wvz6zlSWxDmO1VACn%2BvUBKF8%2B44%3D","lecture-4-tuples-list-slicing-list-comprehension-strings",1794446559,{"doc_id":198,"doc_title":199,"file_type":137,"home_preview_img_url":200,"slug":201,"view_count":8,"category_name":30,"create_tm":202},763092,"Selenium Full Material Updated Greens","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230045654967/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=Cdd0vcA%2FQbv%2BVQpk8iWA4XkL%2FOs%3D","selenium-full-material-updated-greens",1795999623,{"doc_id":204,"doc_title":205,"file_type":137,"home_preview_img_url":206,"slug":207,"view_count":24,"category_name":30,"create_tm":208},670916,"cheat_sheet-python-final-medium - List Comprehension & Indexing","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988704036/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=m1tOOsoRLkitO6m%2B%2BuDfVuLvz2o%3D","cheat_sheet-python-final-medium-list-comprehension-indexing",1793572695,{"doc_id":210,"doc_title":211,"file_type":137,"home_preview_img_url":212,"slug":213,"view_count":144,"category_name":30,"create_tm":214},5133,"How to Be a Coder","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229696182605/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=DARfCPU1CzqzrwMnmuPXVDo8q7U%3D","how-to-be-a-coder",1776309348,{"doc_id":216,"doc_title":217,"file_type":137,"home_preview_img_url":218,"slug":219,"view_count":81,"category_name":30,"create_tm":220},697975,"Python Variable Types - Variable Assignment, Multiple Assignment, and Standard Data Types","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146715/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=OlYtJhHL%2BaOWK93Zp9ccEgxA84M%3D","python-variable-types-variable-assignment-multiple-assignment-and-standard-data-types",1794446554]