\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{poonsarp} \pdfinfo{ /Title (my.pdf) /Creator (Cheatography) /Author (poonsarp) /Subject (my 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}{22D6C4} \definecolor{LightBackground}{HTML}{F1FCFB} \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{my Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{poonsarp} via \textcolor{DarkBackground}{\uline{cheatography.com/25839/cs/6961/}}} \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}poonsarp \\ \uline{cheatography.com/poonsarp} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 11th 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.38896 cm} x{2.58804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{addition}} \tn % Row 0 \SetRowColor{LightBackground} string + number & crash \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} string + string & combine together \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} number + number & math-addition \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.59264 cm} x{3.38436 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{multiplication}} \tn % Row 0 \SetRowColor{LightBackground} string * string & CRASH \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} string * number & combines the strings multiple time \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} number * number & math (multiply) \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} string ** number & CRASH \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} number ** number & Exponent(Math) \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} string ** number & CRASH \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{condition}} \tn % Row 0 \SetRowColor{LightBackground} If & If the statement is true then do \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} :then & command under then else do \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} else & command under else \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} while & While this is true loop the command under the conditional \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} While True & loops forever \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} for each item in name of list & For every item in the list repeat the command under the loop that many times. (a string is a list too) \tn % Row Count 14 (+ 5) % Row 6 \SetRowColor{LightBackground} for...in... & loop forever \tn % Row Count 15 (+ 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}{example3(convert 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}{example4(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}{example5(circle radious)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{while True: \newline user\_radius = input("What is your radius of a circle? ") \newline radius = float(user\_radius) \newline pi = float(3.1415) \newline area = (pi) * (radius) ** 2 \newline print("The area of the circle", area)} \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}{volumeofprism}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def areaoftriangle(b,h): \newline area = 0.5{\emph{b}}h \newline return area \newline user\_base = float(input("enter the base of the triangle: ")) \newline user\_height = float(input("enter the height of the triangle: ")) \newline print ('the area of trianglr is', areaoftriangle,(user\_base, user\_height)) \newline def volumeofprism(b,h,l): \newline volume = areaoftriangle(b,h)*l \newline return volume \newline user\_lenght = float(input('lenght of prism: ')) \newline print('the volume of prism is', volumeofprism(user\_base,user\_height,user\_lenght))} \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}{Printing values}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Printing values: \newline % Row Count 1 (+ 1) print("hello", "there") \#displays hello there \newline % Row Count 2 (+ 1) print("hello" + "there") \#displays hellothere% Row Count 3 (+ 1) } \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}{Combining Strings (Concatenation)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Combining Strings (Concatenation) \newline % Row Count 1 (+ 1) "hi" + "there" == "hi there" \newline % Row Count 2 (+ 1) "hi" * 5 == "hihihihihi"% Row Count 3 (+ 1) } \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}{loop}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{While Loop with List: \newline % Row Count 1 (+ 1) thelist = {[}4, 3, 2, 1, 0{]} \newline % Row Count 2 (+ 1) index = 0 \# start at the first item \newline % Row Count 3 (+ 1) while index \textless{} len(thelist): \newline % Row Count 4 (+ 1) print (thelist{[}index{]}) \#prints each item \newline % Row Count 5 (+ 1) index = index + 1 \newline % Row Count 6 (+ 1) For-Loop with List: \newline % Row Count 7 (+ 1) forlist = {[}3, 4, 5, 2, 1{]} \newline % Row Count 8 (+ 1) for item in forlist: \newline % Row Count 9 (+ 1) print(item)% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.29402 cm} x{3.68298 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Vocabulary}} \tn % Row 0 \SetRowColor{LightBackground} floating point & decimal number \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} boolean & true or false \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} variable & hold a value and can be change \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} string & a list of character such as number, letter and symbol \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} integer & whole number or counting \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} syntax & grammar or structure of lan \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} value & the number or string can be store in valuable \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.89586 cm} x{4.08114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{function}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{print(-)} & display information on screen \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{input(-)} & receive information from user \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} int(-) & converts a value to an integer \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{float(-)} & change number to decimal number \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} str(-) & a list of number, letter and symbol \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} len(-) & the length of string \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} ''' & Multi-line comment \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} \# & One line comment not include in code \tn % Row Count 13 (+ 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}{letter command}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{print (name.upper()) all capital \newline print (name.lower()) all not capital \newline print (name.capitalize()) first letter capital \newline print (name.title()) every first letter of every word capital} \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}{example (reverse word)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{word = input("Type in an word: ") \newline reverse = "" \newline for letter in word: \newline reverse = letter + reverse \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}{example6(random)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import random \newline intlist = {[}1, 2, 3, 4, 5, 6, 7, 8, 9{]} \newline random\_int = random.choice(intlist) \newline print (intlist, random\_int) \newline fplist = {[}1.3112354, 2.5145496, 3.857498, 4.65454564, 5.7418523, 6.321956, 7{]} \newline random\_fp = random.choice(fplist) \newline print (fplist, random\_fp) \newline strlist = {[}"a", "s", "d", "f", "g", "h"{]} \newline random\_item = random.choice(strlist) \newline print (strlist, random\_item) \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}{example 8}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def printdefinition(word): \newline if word=="variable": \newline print("""a variable is value that can change""") \newline elif word=="function": \newline print("""a function is define box of code that can be reuse""") \newline elif word=="parameter": \newline print("""a parameter is value given to function""") \newline elif word=="argument": \newline print("""a argument is value given to function""") \newline elif word=="function call": \newline print("""a function call is use the function code""") \newline elif word=="string": \newline print("""a string is list of character""") \newline else: \newline print("""unknown""") \newline return \newline while True: \newline user\_input = input("enter word ") \newline \seqsplit{printdefinition(user\_input)}} \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}{example9 (largest number)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def max2(num1, num2): \newline \newline if num1 \textless{} num2: \newline maxvalue = num2 \newline else: \newline maxvalue = num1 \newline return maxvalue \newline print(max2(4,5)) \newline print(max2(6,5)) \newline \newline \newline \newline def max3(num1,num2,num3): \newline maxvalue = num1 \newline if num2 \textgreater{} maxvalue: \newline maxvalue = num2 \newline if num3 \textgreater{} maxvalue: \newline maxvalue = num3 \newline return maxvalue \newline print(max3(1,2,3)) \newline print(max3(1,4,3)) \newline print(max3(5,2,3)) \newline \newline \newline \newline def maxlist(list): \newline maxvalue = list{[}0{]} \newline for item in list: \newline if item \textgreater{} maxvalue: \newline maxvalue = item \newline return maxvalue \newline mylist = {[}1,2,3,4,5{]} \newline print(maxlist(mylist))} \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}{range}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{numberlist = range(5) \newline % Row Count 1 (+ 1) \# is the same as creating the following list \newline % Row Count 2 (+ 1) numberlist2 = {[}0, 1, 2, 3, 4{]} \newline % Row Count 3 (+ 1) for num in range(100): \newline % Row Count 4 (+ 1) print (num) \# prints all numbers from 0 – 99 \newline % Row Count 5 (+ 1) for num in range(5, 50): \newline % Row Count 6 (+ 1) print(num) \#prints all numbers from 5 - 49% Row Count 7 (+ 1) } \tn \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}{calculation}} \tn % Row 0 \SetRowColor{LightBackground} == & equal \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 to \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \textgreater{}= & more than or equal to \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \% & modulo (find remainder) \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} + & add \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} - & subtract \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} * & multiply \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} / & divide and quotient is float \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} // & divide and quotient is integer \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} ** & exponent \tn % Row Count 13 (+ 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}{naming rule}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Rules for naming variables:} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- letters} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{- numbers(not first letter)} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- underscores (\_)} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{- can start with letters or underscores ONLY} \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- NO SPACES} \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}{example2(convert 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}{example7}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def bacon(): \newline print("hello it's bacon") \newline return \newline bacon() \newline \newline def myprint(text): \newline print ("{\bf{{\emph{"+str(text)+"}}}}") \newline return \newline myprint(88) \newline \newline \newline def myprintnew(text, decoration): \newline \seqsplit{print(decoration+str(text)+decoration)} \newline return \newline myprintnew(101, "-=-=-=-=-=-") \newline \newline \newline \newline def doubleit(number): \newline return number{\emph{2 \newline print(doubleit(12121212)) \newline print(doubleit(doubleit(12))) \newline \newline \newline \newline def areaofcircle(radius): \newline if radius \textless{}= 0: \newline return "=-=-=-=-=" \newline pi=3.1415 \newline area=pi}}radius**2 \newline return area \newline \newline user\_radius = float(input("radius:")) \newline print("the area is ",areaofcircle(user\_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}{area of triangle}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def areaoftriangle(b,h): \newline area = 0.5{\emph{ b }} h \newline return area \newline user\_base = float(input("enter the base of the triangle: ")) \newline user\_height = float(input("enter the height of the triangle: ")) \newline print ('the area of trianglr is', areaoftriangle,(user\_base, user\_height))} \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}}{reverse = "" \newline letter\_num = 0 \newline \newline user\_input = input("type in a word:") \newline user\_input = str(user\_input) \newline \newline while letter\_num \textless{} len(user\_input): \newline reverse = user\_input{[}letter\_num{]} + reverse \newline letter\_num = letter\_num + 1 \newline if reverse == user\_input: \newline print("the string is palindrome") \newline else: \newline print ("the string is not palindrome")} \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}{vocab}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Vocabulary: \newline % Row Count 1 (+ 1) syntax, variable, Boolean, string, integer, float, \newline % Row Count 3 (+ 2) list, comment, character, conditional, modulo, \newline % Row Count 4 (+ 1) if/elif/else, loop, range, parameter, argument, \newline % Row Count 5 (+ 1) function call% Row Count 6 (+ 1) } \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}{list}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Lists: \newline % Row Count 1 (+ 1) mylist = {[}2,3,4,5{]} \# create a list \newline % Row Count 2 (+ 1) \#select an item from a list \newline % Row Count 3 (+ 1) print (mylist{[}0{]}) \#selects first item and displays 2 \newline % Row Count 5 (+ 2) \# len() determines the length of the list \newline % Row Count 6 (+ 1) print (len(mylist)) \# displays 4 \newline % Row Count 7 (+ 1) mylist.append(5) \# adds an item to the end of the list% Row Count 9 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}