\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{hacklnw1} \pdfinfo{ /Title (hacklnwmuids.pdf) /Creator (Cheatography) /Author (hacklnw1) /Subject (HacklnwMuids 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}{57CEE6} \definecolor{LightBackground}{HTML}{EAF8FB} \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{HacklnwMuids Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{hacklnw1} via \textcolor{DarkBackground}{\uline{cheatography.com/25872/cs/6999/}}} \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}hacklnw1 \\ \uline{cheatography.com/hacklnw1} \\ \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}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Math}} \tn % Row 0 \SetRowColor{LightBackground} + & plus \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} - & minus \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} * & multiply \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} / & divide give decimal \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} == & equal to \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} != & not equal to \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \textless{} & less than \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \textgreater{} & more than \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} \textless{}= & less than or equal to \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} \textgreater{}= & more than or equal to \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} \% & to find remainder \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} ** & power \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} // & divide give integer \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}{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}{Radius pi}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{while True: \newline user\_radius = input("Please enter the radius of the circle") \newline radius = float(user\_radius) \newline pi = 3.1415 \newline \newline area = pi{\emph{radius}}*2 \newline \newline print ("The area of the circle is", 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}{==}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{myboolean = 2 == 3 \newline \newline if myboolean: \newline print ("truth") \newline else: \newline print ("lies")} \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}{0,01,012,0123,01234}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{mystring = ''" \newline count = 0 \newline while count \textless{}= 4: \newline mystring = mystring + str(count) \newline print (mystring) \newline count = count + 1 \newline \newline mystring = "" \newline for num in range(5): \newline mystring = mystring + str(num) \newline print (mystring)} \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}{1 * 1 = 1}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def \seqsplit{multiplicationTable(num):} \newline \newline multi = 0 \newline while multi \textless{} 10: \newline multi = multi + 1 \newline user\_output = num{\emph{multi \newline print ( num,"}}",multi,"=",user\_output) \newline \newline \newline user\_num = int(input("Enter the number: ")) \newline multiplicationTable(user\_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}{Fibonacci}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{num1 = 0 \newline num2 = 1 \newline fibonacci = num1 + num2 \newline output = "0,1" \newline while fibonacci \textless{} 50: \newline output = output +","+ str(fibonacci) \newline num1 = num2 \newline num2 = fibonacci \newline fibonacci = num1 + num2 \newline print (output)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.68298 cm} p{1.29402 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Boolean}} \tn % Row 0 \SetRowColor{LightBackground} False or True & True \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} False and True & False \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} True and False & False \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} True and True & True \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} False or False & False \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.79172 cm} x{3.18528 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Multiplication and Exponent}} \tn % Row 0 \SetRowColor{LightBackground} string * number & Repeat that string by number \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} string * string & CRASH! \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} number * number & Multiply (Math) \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} string ** string & 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}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{String {\emph{ Number \newline num = 1 \newline stri = str(num) \newline \newline print (stri }} 3) \newline \_\_\_\_\_\_\_\_\_\_\_\_\_\_ \newline \#After running program \newline 111} \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}{Hex}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{user\_number = input("Enter number to convert to hex : ") \newline \newline number = int(user\_number) \newline \newline hex\_string = '' \newline while (number \textgreater{} 0): \newline remainder = number \% 16 \newline if remainder == 10: \newline remainder = 'A' \newline elif remainder == 11: \newline remainder = 'B' \newline elif remainder == 12: \newline remainder = 'C' \newline elif remainder == 13: \newline remainder = 'D' \newline elif remainder == 14: \newline remainder = 'E' \newline elif remainder == 15: \newline remainder = 'F' \newline \newline hex\_string = str(remainder) + str(hex\_string) \newline number = number // 16 \newline \newline print ("Hex 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}{Math}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{print(2)\#interger \newline print(2.5)\#floationg point \newline print("this is a string")\#string \newline \newline myStr = "hello" \newline \newline print (myStr) \newline \newline print ("hello" , 1, 2) \newline \newline print (""" \newline hello \newline yeah \newline . \newline . \newline . \newline . \newline """) \newline \newline """ \newline This multi line comment \#lol \newline """ \newline \newline \#variable name \newline \#can have interger, lowercase/uppercase letters, underscores \newline \newline \#Mate operators \newline \# + - / {\emph{ \newline \#exponents \newline \#2 to the power of 3 \newline \newline print (2 }} 2 {\emph{2 ) \newline print (2 }}{\emph{ 3) \newline \newline \#Modulo/Remainder \newline print (4\%2) \#remainder = 0 \newline print (33\%2) \#remainder = 1 \newline \newline \#convert to floating point \newline print (float(2)) \newline \newline \#covert to a string \newline myint = 1 \newline mystring = str(myint) \newline print (mystring }} 3) \newline \newline \#true/false - Boolean \newline \newline print (2 \textless{} 3)} \tn \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}{Addition}} \tn % Row 0 \SetRowColor{LightBackground} string + string & Combination of string \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} string + number & CRASH! \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} number + number & Add (Math) \tn % Row Count 3 (+ 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}{Reverse}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{word = input("Please put a word :") \newline reverse = "" \newline letternum = 0 \newline \newline while letternum \textless{} len(word): \newline reverse = (word{[}letternum{]}) + reverse \newline letternum = letternum + 1 \newline \newline print ("Reverse: ",reverse) \newline \newline for num in word: \newline reverse = num + 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}{Guess}} \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}{Even,Odd number}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{even = 0 \newline odd = 0 \newline while True: \newline user\_num = int(input("Enter the number :")) \newline if user\_num \textgreater{}= 0: \newline if user\_num \% 2 == 0: \newline even = even + 1 \newline else: \newline odd = odd + 1 \newline else: \newline print ("Even number :", even) \newline print ("Odd number :", odd) \newline break} \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}{Definition}} \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)}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}