\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{kawkub1} \pdfinfo{ /Title (python-123.pdf) /Creator (Cheatography) /Author (kawkub1) /Subject (Python 123 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}{72A356} \definecolor{LightBackground}{HTML}{F6F9F4} \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 123 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{kawkub1} via \textcolor{DarkBackground}{\uline{cheatography.com/25790/cs/6924/}}} \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}kawkub1 \\ \uline{cheatography.com/kawkub1} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 12th February, 2016.\\ Updated 12th 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{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Vocabulary}} \tn % Row 0 \SetRowColor{LightBackground} Variable & Something that can be change \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} String & A list of characters \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} Integer Number & Whole number/counting number \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} Float Number & The number in decimal \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} Syntax & Grammar \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} Modulo & Remainder \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} Boolean & True\&False \tn % Row Count 9 (+ 1) \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}{Function}} \tn % Row 0 \SetRowColor{LightBackground} print() & display info. on the screen \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} input() & receives info from the user \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} int() & convert a value to an interger \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} float() & convert a value to a floating point \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} str() & convert a value to a string \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} len() & The length of the string \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \# & comment \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} if then else & if ... is True "then" will work or if it False then "else" will work \tn % Row Count 11 (+ 3) % Row 8 \SetRowColor{LightBackground} While: True & Forever Loop \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} for & Looping Forever \tn % Row Count 14 (+ 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}{Function largest number}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def max2(num1,num2): \newline if num1 \textgreater{} num2: \newline maxvalue = num1 \newline elif num2 \textgreater{} num1: \newline maxvalue = num2 \newline return maxvalue \newline \newline \#function call \newline print(max2(92,3)) \newline print(max2(4,5)) \newline \newline def max3(num1,num2,num3): \newline maxvalue = num1 \newline \newline if num2 \textgreater{} maxvalue: \newline maxvalue = num2 \newline elif num3 \textgreater{} maxvalue: \newline maxvalue = num3 \newline return maxvalue \newline \newline \#function call \newline print(max3(92,5,6)) \newline print(max3(8,9,7)) \newline print(max3(99,40,49)) \newline \newline def maxlist(list): \newline maxvalue = list{[}0{]} \newline for num in list: \newline if maxvalue \textless{} num: \newline maxvalue = num \newline return maxvalue \newline \newline mylist = 3,5476,134,8,451,87 \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}{Naming Convention}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Rules for giving name} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{-letter} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{-numbers} \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}}{Valid Name} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- \_myStr} \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{- my3} \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- Hello\_there} \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Invalid Name} \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- 3mt = "hi" -{}- cannot start with number} \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{- first name = "hi"} \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{- first-name} \tn % Row Count 12 (+ 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}{Volume and Triangle}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def areaOfTriangle(base,height): \newline area=1/2 {\emph{ base }} height \newline return(area) \newline \newline user\_base = float(input('Enter the base of the triangle: ')) \newline user\_height = float(input('Enter the height of the triangle: ')) \newline \newline \#function call \newline print('The area of the triangle is',areaOfTriangle(user\_base,user\_height)) \newline \newline \newline def volumeOfPrism(base,height,prism\_height): \newline volume = areaOfTriangle(base,height) * prism\_height \newline \newline return (volume) \newline \newline user\_prism\_height = float(input('Enter the prism height:')) \newline print ('the volume of the prism is', volumeOfPrism(user\_base, user\_height, user\_prism\_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}}{def isPalindrome(word): \newline if reverse\_item == user\_word: \newline return "true" \newline else: \newline return "false" \newline while True: \newline user\_word = input('What is the word: ') \newline length = len(user\_word) \newline if user\_word == 'quit': \newline break \newline else: \newline print("Length of the word is: ",(length)) \newline \newline reverse = "" \newline \newline for item in user\_word: \newline reverse = item + reverse \newline \newline reverse\_item = reverse \newline \newline s = 0 \newline while s \textless{} length / 2 + 1 : \newline if reverse\_item{[}s{]} == user\_word{[}s{]}: \newline print(user\_word, "is a palindrome") \newline break \newline s = s + 1 \newline else: \newline print(user\_word, "is not a palidrome") \newline break} \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}{Math}} \tn % Row 0 \SetRowColor{LightBackground} = = & equal to \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} != & not equal to \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{} & less than \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \textgreater{} & greater 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{}= & greater than or equal to \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \% & Modulo, Find the remainder \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \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 + String & combine together \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} string + number & CRASH \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} number + number & math \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Multiplication and Exponent}} \tn % Row 0 \SetRowColor{LightBackground} string * number & combine the string \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} string * string & CRASH \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} number * number & math \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} string ** string & CRASH \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} number ** number & Math \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} string ** number & CRASH \tn % Row Count 6 (+ 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}{Example}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Print (2) -interger} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Print (2.4) - Floating Point} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Print (myStr) - variable} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Print ("Hello") - string} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Print (myStr,"Hi",2,1,0) -{}- commas} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{myStr = "Hi"} \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{mystr - name} \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{"Hi" - value can change} \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{print (int(1.5)) - 1} \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{print (float(1)) - 1.0} \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{print (4\%2) - 0} \tn % Row Count 11 (+ 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}{Randomizer}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{""" \newline Group member: Kim, Pop, and Earn \newline \newline Group: 10-03 \newline """ \newline import random \newline mylist = ('lion' , 'tiger' , 'dog' , 'bee' , 'cat') \newline print (mylist) \newline random\_item = random.choice(mylist) \newline print (random\_item) \newline chance = 7 \newline score = 0 \newline while chance \textgreater{} 0: \newline user\_guess = input("Guess a word: ") \newline \newline if user\_guess == random\_item: \newline score = score + 100 \newline print ("That's Correct!") \newline print ('score=',(score)) \newline random\_item = random.choice(mylist) \newline \newline else: \newline \newline if user\_guess in mylist: \newline chance = chance - 1 \newline print ("Sorry, wrong choice") \newline print ("chance =", (chance)) \newline print ("The word is: ",random\_item) \newline random\_item = random.choice(mylist) \newline print ("score",(score)) \newline else: \newline chance = chance - 1 \newline print ("Sorry, that is not even in the list") \newline print ("chance =", (chance)) \newline random\_item = random.choice(mylist) \newline print ("score",(score)) \newline \newline if chance == 0: \newline print ("GAME OVER!") \newline print (' Answer =', (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}{Area}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def areaOfCircle(r): \newline pi = 3.1415 \newline area = 2{\emph{pi}}r \newline return area \newline \newline user\_radius = float(input("Enter the radius: ")) \newline print("The area of the circle is", \seqsplit{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}{Calculating Program}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def calc(num1, num2, operation): \newline if operation == "sum": \newline return sum(num1, num2) \newline elif operation == "product": \newline return product(num1,num2) \newline elif operation == "diff": \newline return diff(num1,num2) \newline elif operation == "div": \newline return div(num1,num2) \newline \newline def sum(a, b): \newline return (a + b) \newline \newline def product(a, b): \newline return (a * b) \newline \newline def diff(a, b): \newline return (a - b) \newline \newline def div(a, b): \newline return (a / b) \newline \newline print (calc(1,2,"sum")) \newline print(calc (4,2, "diff")) \newline print (calc (9, 3, "div")) \newline print(calc (2, 12, "product"))} \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}{Palindrome2}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{''' \newline Kim Jaroensattayatham(1003) \newline ''' \newline def isPalindrome(word): \newline index = 0 \newline reverse = "" \newline while int(index) \textless{} len(word): \newline reverse = word{[}index{]} + reverse \newline index = int(index) + 1 \newline \newline if reverse == user\_input: \newline return "true" \newline else: \newline return "false" \newline \newline while True: \newline user\_input = input("please enter the word") \newline if user\_input == "quit": \newline break \newline print(len(user\_input)) \newline \seqsplit{print(isPalindrome(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}{Reverse Word}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{while True: \newline % Row Count 1 (+ 1) word = input("enter your word") \newline % Row Count 2 (+ 1) index = 0 \newline % Row Count 3 (+ 1) reverse = ' ' \newline % Row Count 4 (+ 1) while int(index) \textless{} len(word) \newline % Row Count 5 (+ 1) reverse = word{[}index{]} + (reverse) \newline % Row Count 6 (+ 1) index = int(index) + 1 \newline % Row Count 7 (+ 1) print("Reverse: ", reverse)% Row Count 8 (+ 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}{Convert To BInary}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{user\_number = ' ' \newline % Row Count 1 (+ 1) while user\_number != ' 0 ' \newline % Row Count 2 (+ 1) user\_number = input("Enter a number to convert to binary") \newline % Row Count 4 (+ 2) number = int(user\_number) \newline % Row Count 5 (+ 1) binary\_string = ' ' \newline % Row Count 6 (+ 1) while(number \textgreater{} 0) \newline % Row Count 7 (+ 1) remainder = number \%2 \newline % Row Count 8 (+ 1) binary\_string = str(remainder) + binary\_string \newline % Row Count 9 (+ 1) number = number//2 \newline % Row Count 10 (+ 1) print("Binary string is", binary\_string)% Row Count 11 (+ 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}{Countdown Machine}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{user\_number = input("What number do you want to countdown") \newline % Row Count 2 (+ 2) number = int (user\_number) \newline % Row Count 3 (+ 1) countdown\_string = ' ' \newline % Row Count 4 (+ 1) while number \textgreater{} 0: \newline % Row Count 5 (+ 1) countdown\_number = countdown\_string + str(number) + " " \newline % Row Count 7 (+ 2) number = number - 1 \newline % Row Count 8 (+ 1) \#print(number) \newline % Row Count 9 (+ 1) print(countdown\_string)% Row Count 10 (+ 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}{IMPORT}} \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 = {[}1.0,1.2,1.3{]} \newline random\_fp = random.choice(fplist) \newline print(fplist, random\_fp) \newline \newline strlist = {[}'a','b','c','d','e'{]} \newline random\_str = random.choice(strlist) \newline print(strlist, random\_str) \newline \newline mylist = {[}1,1.0,'hello'{]} \newline random\_item = random.choice(mylist) \newline print (mylist, random\_item) \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}{Asking Name Code}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{firstname = input(" what is your firstname? ") \newline % Row Count 1 (+ 1) lastname = input(" what is your lastname?") \newline % Row Count 2 (+ 1) fullname = firstname + " " + lastname \newline % Row Count 3 (+ 1) print (fullname) \newline % Row Count 4 (+ 1) letternum = int(input(" what is the letter number? ")) \newline % Row Count 6 (+ 2) if len(fullname) \textless{} letternum : \newline % Row Count 7 (+ 1) print("Invalid letter number, try again! ") \newline % Row Count 8 (+ 1) else : \newline % Row Count 9 (+ 1) print (fullname{[}letternum{]}) \newline % Row Count 10 (+ 1) letterprint = int(input(" how many time to print letter ")) \newline % Row Count 12 (+ 2) if letterprint \textgreater{} 100 : \newline % Row Count 13 (+ 1) print (" too many letters to print ") \newline % Row Count 14 (+ 1) else : \newline % Row Count 15 (+ 1) print (fullname{[}letternum{]} * letterprint)% Row Count 16 (+ 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}{rdtfghjbkn}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{''' \newline theList = ('A' , 'B' , 'C' , 'D') \newline for item in theList: \newline print (item) \newline whileList = ('a' , 'b' , 'c') \newline index = 0 \newline while index \textless{} len(whileList): \newline print(whileList{[}index{]}) \newline index = index + 1 \newline \newline while True: \newline user\_input = input("Enter your word") \newline print (len(user\_input)) \newline if user\_input == "exit": \newline break \newline \newline def theFunction(): \newline while True: \newline user\_input = input ("Enter the word:") \newline if user\_input == "stop": \newline break \newline \#call the function \newline theFunction() \newline \newline def computeThis(a1,b2): \newline theproduct = a1 {\emph{ b2 \newline print(theproduct) \newline return \newline computeThis(1,2) \newline ''' \newline \newline def finalFunction(string): \newline print("{\bf{}}{\emph{",string,"}}}}*") \newline return \newline finalFunction("Kim")} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}