\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Sonnylnw MUIDS} \pdfinfo{ /Title (python.pdf) /Creator (Cheatography) /Author (Sonnylnw MUIDS) /Subject (Python Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{F000D8} \definecolor{LightBackground}{HTML}{FEEFFC} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Python Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Sonnylnw MUIDS} via \textcolor{DarkBackground}{\uline{cheatography.com/25876/cs/6997/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Sonnylnw MUIDS \\ \uline{cheatography.com/sonnylnw-muids} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 5th February, 2016.\\ Updated 11th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Function}} \tn % Row 0 \SetRowColor{LightBackground} str() & make the number or symbol \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} input() & to get infomation from the user \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} print() & to show some infomation that in the code \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} int() & the integers \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} len() & length of the string \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \# & comment \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \seqsplit{"""........................"""} & multiple line comment \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{List2}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{mylist = {[}1,2,3,4,5{]} \newline mulist2 = {[}'hi', 'hello', 'anything'{]} \newline mylist3 = {[}1, 'hello', 2.5 \newline \newline print (mylist) \newline print (mylist2) \newline print (mylist3) \newline \newline number = range(100) \newline for nm in number: \newline print (num)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Name strip}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{firstname = input("what is your first name? ") \newline lastname = input("what is your lastname? ") \newline \newline fullname = firstname + " " + lastname \newline \newline print("Your fullname is ") \newline print (fullname) \newline \newline letternumber = input("what is letter number? ") \newline \newline mynumber = int(letternumber)-1 \newline \newline if (mynumber) \textgreater{} len(fullname): \newline print ("invalid letter number, try again") \newline else: \newline print (fullname{[}mynumber{]}) \newline \newline repeat = input("how many times you want to print the letter? ") \newline \newline myrepeat = int(repeat) \newline \newline if (myrepeat) \textgreater{} 99: \newline print ("too many letter! ") \newline else: \newline print(fullname{[}mynumber{]}*(myrepeat))} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Import random}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import random \newline chance = 3 \newline score = 0 \newline \newline mylist = {[}'Hack', 'ToeyD.', 'Patter','Tim','Lily'{]} \newline random\_item = random.choice(mylist) \newline while chance \textgreater{} 0: \newline \newline print (mylist) \newline \newline print ("Chances Remaining =",chance) \newline guess = input("Guess a word from the above :") \newline \newline if guess == random\_item: \newline score = score + 100 \newline print ("That's correct!","The score is :",score) \newline random\_item = random.choice(mylist) \newline else: \newline print ("Sorry, wrong choice!") \newline chance = chance - 1 \newline if guess in mylist: \newline print ("") \newline else: \newline print ("Sorry,that is not even in the list!") \newline if chance == 0: \newline print ("Game Over! The word was",random\_item) \newline print ("Final score: ",score)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{write alltheoutcome}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{mystring = "" \newline count = 0 \newline while count \textless{} 5: \newline mystring = mystring + str(count) \newline print (mystring) \newline count = count + 1 \newline \newline \newline OUTCOMEIS \newline 0 \newline 01 \newline 012 \newline 0123 \newline 01234} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{areaofEllipse}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def areaofEllipse(radius1, radius2): \newline pi = 3.142 \newline area = pi{\emph{radius1}}radius2 \newline return area \newline \newline ra1 = int(input("put in the radius 1")) \newline ra2 = int(input("put in the radius 2")) \newline print (areaofEllipse(ra1, ra2)) \newline \newline \newline OUTPUT \newline put in the radius 14 \newline put in the radius 25 \newline 62.839999999999996} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{DEFINATION}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def printDefinition(word): \newline if word == "variable": \newline print (""" \newline A variable is the the thing that can be changed. \newline """) \newline elif word == "parameter": \newline print (""" \newline A parameter is the limiting factor \newline """) \newline elif word == "argument": \newline print (""" \newline An argument is the identifier that you give to function \newline """) \newline elif word == "string": \newline print (""" \newline A string is something that can be repeated by the number. \newline """) \newline elif word == "function call": \newline print (""" \newline A function call is the word you use to reuse the function. \newline """) \newline else: \newline print ("unknown word") \newline \newline while True: \newline user\_input = input("Please type the word :") \newline \seqsplit{printDefinition(user\_input)} \newline \newline \newline OUTPUT \newline Please type the word :variable \newline \newline A variable is the the thing that can be changed.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Vocab}} \tn % Row 0 \SetRowColor{LightBackground} Variable & The unknow that can be change \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Float & Decimal number \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} String & Number, Letter, and symble \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Syntax & The programing language \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} Boolean & True or False \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \seqsplit{Paramiter} & some thing you give to function \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Reverse}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{reverse = "" \newline letter\_num = 0 \newline \newline word = input('type in a word: ') \newline """ \newline while letter\_num \textless{} len(word): \newline reverse = word{[}letter\_num{]} + reverse \newline letter\_num = letter\_num + 1 \newline """ \newline for letter in word: \newline reverse = letter + reverse \newline \newline print ('reverse: ',reverse)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Reverse2}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{hello = "hello there!" \newline \newline out = "" \newline \newline for letter in hello: \newline out = letter+out \newline \newline \newline print(out)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Number to Binary}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{user\_number = input("Enter number to convert to binary : ") \newline \newline number = int(user\_number) \newline \newline binary\_string = '' \newline while (number \textgreater{} 0): \newline remainder = number \% 2 \newline binary\_string = str(remainder) + str(binary\_string) \newline number = number // 2 \newline \newline print ("Binary string is",binary\_string)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Countdown}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{user\_number = input("Please enter a number: ") \newline \newline number = int(user\_number) \newline \newline countdown\_string = '' \newline \newline while number \textgreater{} 0: \newline countdown\_string = countdown\_string + str(number) \newline number = number - 1 \newline print (countdown\_string)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Find Area of Circle}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def aofc(r): \newline if r \textless{}= 0: \newline return "Error: radius \textless{}=0" \newline pi = 3.1415 \newline area = pi {\emph{ r }}* 2 \newline return area \newline user\_radius = input("enter the radius: ") \newline radius = float(user\_radius) \newline print("The area of the circle is", aofc(radius))} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Max value}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\# write a function that returns the largest of two values \newline \# name: max2 \newline \# arguments: num1, num2 \newline \# return: the largest value \newline \newline \newline def max2 (num1, num2): \newline maxvalue = num1 \newline \newline if num2 \textgreater{} num1: \newline maxvalue = num2 \newline \newline return maxvalue \newline \newline print(max2(10,9)) \newline print(max2(1,9)) \newline \newline \newline \# write a function that returns the largest of three values \newline \# name: max3 \newline \# arguments: num1, num2, num3 \newline \# return: the largest value \newline \newline \newline def max3 (num1, num2, num3): \newline maxvalue = num1 \newline \newline if num2 \textgreater{} maxvalue: \newline maxvalue = num2 \newline \newline if num3 \textgreater{} maxvalue: \newline maxvalue = num3 \newline \newline return maxvalue \newline \newline print(max3(3,5,9))} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Decision Making/Conditional Statements:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{if 3 \textless{} 2: \#if statement must compare two Booleans \newline print ('3 is less than 2') \newline elif 4 \textless{} 2: \#can have 0 or more elif statements \newline print ('4 is less than 2') \newline elif 5 \textless{} 2: \newline print ('5 is less than 2') \newline else: \#can have 0 or 1 else statement at the end \newline print ('none of the above are True')} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{MATH}} \tn % Row 0 \SetRowColor{LightBackground} string+string & Combine \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} string - number & CRASH \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} number + number & ADDING \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} string*number & combine \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} string*string & CRASH \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} number*number & Multiply \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} string**string & CRASH \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} string**number & CRASH \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} number\%number & remainder \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} number**number & Exponent \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} = & Equal \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} == & Compare \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} // & Divide anser in Interger \tn % Row Count 13 (+ 1) % Row 13 \SetRowColor{white} / & Divide anser in Floot \tn % Row Count 14 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Symbol}} \tn % Row 0 \SetRowColor{LightBackground} == & Equal to... \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} != & Not equal \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{} & Less than \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \textgreater{} & More than \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \textless{}= & Less than or equal \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \textgreater{}= & More than or equal \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \% & Modulo/Find remainder \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{List}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{shoplist = {[}'son', 'goo', 'maaa', 'laaaa'{]} \newline print(shoplist{[}2{]}) \newline """ \newline item\_number = 0 \newline while item\_number \textless{} len(shoplist): \newline print ("list item:", shoplist{[}item\_number{]}) \newline item\_number = item\_number + 1 \newline """ \newline out = 0 \newline for item in shoplist: \newline out = out + 1 \newline \#print ('list item:',item) \newline print (out)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Number to Hex}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{user\_number = input("please enter a number: ") \newline number = int(user\_number) \newline hex\_string = ' ' \newline while (number \textgreater{} 0): \newline remaider = number \% 16 \newline if remaider == 10: \newline remaider = 'A' \newline elif remaider == 11: \newline remaider = 'B' \newline elif remaider == 12: \newline remaider = 'C' \newline elif remaider == 13: \newline remaider = 'D' \newline elif remaider == 14: \newline remaider = 'E' \newline elif remaider == 15: \newline remaider = 'F' \newline \newline hex\_string = str(remaider) + str(hex\_string) \newline number = number // 16 \newline print ("Hexadecimal string is 0x", hex\_string)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Import list}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import random \newline \newline intlist = {[}1, 2, 3, 4, 5{]} \newline random\_int = random.choice(intlist) \newline print (intlist,random\_int) \newline \newline fplist = {[}float(1), float(2), float(3), float(4), float(5){]} \newline random\_fp = random.choice(fplist) \newline print (fplist,random\_fp) \newline \newline strlist = {[}str('son'), str('hack'), str('pom'), str('phon'){]} \newline random\_str = random.choice(strlist) \newline print (strlist,random\_str) \newline \newline mylist = {[}'son', 'jan', 'feb', 'mar'{]} \newline random\_my = random.choice(mylist) \newline print (mylist,random\_my) \newline \newline myvar1 = 1 \newline myvar2 = 2 \newline myvar3 = 3 \newline varlist = (myvar1, myvar2, myvar3) \newline random\_var =random.choice(varlist) \newline print (varlist,random\_var)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Palindrome}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{''' \newline Surawut Sartpant \newline Son 1002 \newline Python Assignment-Palindrome \newline ''' \newline def isPalindrome(word): \newline numlen = 0 \newline while numlen \textless{} long // 2 + 1: \newline if word{[}numlen{]} != word{[}-numlen-1{]}: \newline return False \newline elif word{[}numlen{]} == 1: \newline return True \newline numlen += 1 \newline else: \newline return True \newline \newline \newline while True: \newline word = input(" Insert your word: ") \newline long = len(word) \newline \newline if word == "quit": \newline break \newline else: \newline print (long) \newline \newline numlen = 0 \newline \newline if isPalindrome(word) == True: \newline print (word,"it is a palindrome") \newline else: \newline print (word,"it is not a palindrom") \newline \newline """ \newline output \newline Insert your word: klk \newline 3 \newline klk it is a palindrome \newline Insert your word: quit \newline """} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}