Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
100%
(1)
100% found this document useful (1 vote)
108 views
78 pages
2021-03-07 Coding For Beginners
Uploaded by
Daniel Florea
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save 2021-03-07_Coding_For_Beginners For Later
Share
100%
100% found this document useful, undefined
0%
, undefined
Print
Embed
Report
100%
(1)
100% found this document useful (1 vote)
108 views
78 pages
2021-03-07 Coding For Beginners
Uploaded by
Daniel Florea
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save 2021-03-07_Coding_For_Beginners For Later
Share
100%
100% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save 2021-03-07_Coding_For_Beginners For Later
You are on page 1
/ 78
Search
Fullscreen
Coding Tricks and HEE Rediscover Your Device Advanced Guides & Tips Next level Secrets & FixesDiscover more of our guides... =a = = = Photoshop} Android | Mac Black & White Tricks and Tips | Tricks and Tips |. Tricks and Tips Photogra i cl d = h = Codi = fe & Python oul Python ‘odin a on Computing Tricks and Tips 6 Tricks and Tips Tricks and Tips es = Photography FRITZ!Box Tricks and Tips | Tricks and Tips = Landscape Photograph Tricks snd Tins = Instagram Tricks and TipsCoding Tricks and Tips Welcome back... Having completed our exclusive For Beginners digital guidebook, we have taught you all you need to master the basics of your new device, software or hobby. Yet that's just the start! Advancing your skill set is the goal of all users of consumer technology and our team of long term industry experts will help you achieve exactly that. Over this extensive series of titles we will be looking in greater depth at how you make the absolute most from the latest consumer electronics, software, hobbies and trends! We will guide you step-by-step through using all the advanced aspects of the technology that you may have been previously apprehensive at attempting. Let our expert guide help you build your understanding of technology and gain the skills to take you from a confident user to an experienced expert. Over the page our journey continues, and we will be with you at every stage to advise, inform and ultimately inspire you to go further.10 2 4 16 18 20 What isa Batch File? Getting Started with Batch Files Getting an Output Playing with Variables Batch File Programming Loops and Repetition Creating a Batch File Game 24 26 28 30 32 34 36 38 40 42 44 46 48 50 54 56 58 60 SSases Why Linux? ‘The Best Linux Distributions Equipment You Will Need Creating a Linux Installer on Windows Installing Linux on a PC Installing a Virtual Environment Installing Linux in a Virtual Environment Getting Ready to Code in Linux Creating Bash Scripts - Part 1 Creating Bash Scripts - Part 2 Creating Bash Scripts - Part 3 Creating Bash Scripts ~ Part 4 Creating Bash Scripts ~ Part 5 Command Line Quick Reference Breer koe OMS acd Planning your Code Finding Resources Creating a Loading Screen Planning a Text Adventure Text Adventure Script Retro Coding Text Animations Common Coding Mistakes Python Beginner's Mistakes C++ Beginner's MistakesMaster Python Set es Orgone. ery te tL) Cres erences a = a aot ahs eS prc yE a (3 Steals a PA Par ite reais va i i Be alt ‘ nD L 2 | ee G dents occas Rr teste sce ne alCoding with — Windows 10 Batch Files Did you know that Windows has its own built- 7 in scripting language? Batch files have been eI roa ea a PCC iCute POUR ae eS Lae Eee ee ea 8 eee ee el ed they were thirty years ago. eee eure) administrators still use, so it's worth spending ACA ar) Re ku cu eta) introduces batch files, and covers user Pe RRC CMC Se Rue ca Geen ec ur usCoding with Windows 10 Batch Files What is a Batch File? -BAT MAN ‘AWindows batch file is simply a script file that runs a series of commands, one line at a time, much in the same Fashion as a Linux script. The series of commands are executed by the command line interpreter and stored in a plain text file with the BAT ‘extension; this signifies to Windows that it’s an executable file, in this case, a script. Batch files have been around since the earliest versions of Microsoft line in turn, loading programs that would activate the mouse or 0S. Although not exclusively 8 Microsoft scripting file, batch files optical drive into the memory areas assigned by the Config ys File ‘are mainly associated with Microsoft's operating systems. Inthe early days, when a PC booted into a version of DOS (which produced The DOS user ofthe day could opt to create different Autoexec. a simple command prompt when powered up, the batch file was bat files depending on what they wanted to do, For example, i Used in the Farm of a system file called Autoexec bat. Autoexec they wanted to playa game and have as much memory available bat was a script that automatically executed (hence Autoexec) ‘as possible, they'd create a Config sys and Autoexecbat set of files ‘commands once the operating system had finished dealing with the that loaded the bare minimum of drivers and so on. they needed Config.sys file ‘access to the network, an Autoexec bat file could be created to ‘when a user powered up their DOS-based ‘computer, and once the 8105 had finished checking the system memory {and s0.0n, 00S would look tothe Config sys file to load any specific display requirements and hardware drivers, allocate them a slot inthe available memory, assign ‘any memory managers, and tell the system where the Command.com ile, whichis the command line interpreter for DOS, was. ‘Once it had done that, then the Autoexec:bat ile took ‘over and ran through each ‘The Autoexecbat file was a PCuser’s First experience with abatch wor bmpublicstions comBatch files are plain text and often created using Notepad. Batch files were often used as utility programs, to help users with ‘complex tasks. load the network card driver and automatically gain access to the network. Each of these unique setups would be loaded on toa Floppy sk and booted as and when required by the user. ‘The Autoexec.bat was the first such file many users came across in their PC-based computing lives; since many had come froma 16-bit Cr even &-bit backaround; remember, tis was the late eighties {and early nineties. The batch file was the user's primary tool for ‘automating tasks, creating shortcuts and adventure games and translating complex processes into something far simpler. Nowadays however, batch file isnt just for loading in drivers and such when the PC boots. You can use a batch file inthe same way {as any other scripting language file, n that you can program it to ‘ask For user input and display the results on the screen; or save to afileand ittoa locally or network attached printer. You can create scripts to back up your files to various locations, compare smps and only back up the most recently changed content as wel as program the script todo allthis automaticaly. Batch files are emarkably powerful and despite them not being as commonly used ‘as they were during the older days of DOS, they are stilthere and canbe utilised even in the latest version of Windows 10; and can be as complex or simple as you want them to be. ‘So what do you need to start batch file programmingin Windows? Jel, along as you have Windows 10, or any older version of indows for that matter, you can star batch file programming immediately. All you need is tobe able to open Notepad and get to the command prompt of Windows. We show you how it all works, so ead on, What is a Batch File? BATCH FILE POWER Just like any other programming interface that can directly interrogate and manipulate the system, batch files require acertain amount of care when programming I's hard to damage your system with a bateh ile, asthe more important elements of the madern Windows system are protected by the User Account Control (UAC) security; UAC works by only allowing elevated privileges access to important system files. Therefore ifyou create a batch fie that somehow deletes a system fil, the UAC activates and stop the process. However, if you're working in the command prompt with elevated privileges to begin with, as the Administrator, then the UAC won't question the batch file and continue regardless of what files are being delet That said, you're not likely to create a batch file that intentionally wipes out your operating system. There are system controls in place to help prevent that; but it's worth mentioning as there are bal that contain malicious code designed to create problems, "Much ikea virus, a rogue batch file (when executed with niles available on the internet ministrator privileges) can cause much mayhem and damage. In short, don’t randomly execute any batch file downloaded from the Internet as an Administrator, without First reviewing whatit does. system You can learn more about batch files inthe coming pages, so don't worry too much about destroying your system with one allthis ust demonstrates how powerful the hur ch ile ‘You can create complex batch files or simple ones that display ‘ASCIlimages on screen. ww bdmpublcations comCoding with Windows 10 Batch Files Getting Started with Batch Files ANEW BATCH ‘Throughout this section on batch files we're going to be working with Notepad, the command prompt and within a Folder called ‘Batch Files’. To begin with, let's see how you get to the Windows command prompt. Ea The Windows E=p hile at the command prompt window, enter commani > ° i This ist all the files and directories from pt may look a title re ‘here you ae atthe moment in the system. In this case, thats your daunting to the newcomer Home directory that Windows assigns every user that logsin. You imply another 1 navigate by using the CD command (Change Directory). Try interface (or Shel) used to a access the filesystem. You 7 ‘Then press Return, the command prompt, as you would with the grap interface. To begin, click on the Windows Start button and enter CMD inta the search box. EELED cicctecehcetnetesconmanstonst EEE the mst crnoe an dest (Desktop App) and a new window pops up. The uments>; this means you'e in the Dacuments ‘Command Prompt window isn't much ta lookat to begin with rectory. Now, create anew directory call Batch Files. Ente you can see the Microsoft Windows version number and copyright information followed by the prompt itself. The prompt details the current directory or Folder you're in, together with your username, You need the quotations because without th two directories: Batch and Files, Now change directory int iy created Batch Files ‘You wor't need the quotes to change directories. wor bmpublicstions comNow that you have the directory set up, where you store your batch files, here is how you can create ‘one. Leave the command prompt window open and click on the \Windows Start Button again. This time enter Notepad and click on the search result to open the Notepad program. Notepad isa simple text editor but ideal For creating batch scripts with, FEPPD To create your first batch file, enter the Following into Notepad: @echo off echo Hello World! By default, abatch file displays allthe commands that it runs. through, line by tine. What the @echo off command does is turn that Feature off for the whole script; with the '@ at) sign to apply that command to itself. BSS) When saving anything in Notepad the default extension st, to denote ate fe, However, you want the extension tobe bat. Click on Fle > Save As and navigate tothenenl created Batch Files directory in Documents Clik the drop-down menu Save a5 Type, and select Al Files From the menus In FileName, cal the fle Test bat. Getting Started with Batch Files Backat the command prompt window enter: SNPS ‘diit/w again to list the newly created Test.bat file. By the way, the (w part of dirfw means the files are listed across the screen as opposed to straight down, Enter di iFyou want {although you need more files to view) butts considered easierto read with the /w flag, FEPTED To execute the batch file youve ust created, simply enter its name, Test, in the command prompt window. You don't need to add the bat pat, as Windows recognises itasan executable file, and the only one with that particular name in the current directory. Press return and see how you're greeted with Hello World! n the command prompt The echo command diplaswhateveris aes Suerio to the screen. Right-click the Test.bat file From Windows Explorer and select to add more echo commandsif youll, Ty ths echo off echo Hello World! echo This is my first batch file echo echo With @ blank Line between! Remember to save each new change to the batch fle.EP Coding with Windows 10 Batch Files Getting an Output Peta or eumeu ava UR EME U Tete icc the echo command in the batch file, it’s not very useful at the moment, or interactive meu etacne rk scueukrstcaccnie INPUT, OUTPUT Batch files are capable of taking a normal Windows command and executing it, while also adding extra options and Flags in to the equation. Lesieeting:sinleto began cee aw TRIER Youhne mo dost notstttere iro Sui" batch file called ‘dirview. bat’, short For Directory Sus) indication that the batch file worked as there's view Start wththe @echocff command and under thatsdé" no meeinu ott onthe screen. However ry now open Explorer ad browse oo ers \WOURN, emembetng ‘subst Yura with your Windows username, and dole chk the diviews txt le youcan see the atch Fes otput dir “e:\users\YOURNAME\Docunente\Batch Files” > eo: \usere\YOURNAME\dirview.txt Substitute YOURNAME with your Windows username. The new tine uses the dircommand to lst the \Fyou want to automate the task of opening the contents ofthe directory Batch Files, in your Home text file that contains the output, add the following directory, dumping the output to atextfile called dirview.txtin line tothe batch file: the root of your Home directory. This is done, so thatthe Windows LUAC doesn't require elevated permissions, as everything isin your ‘own Home area, Save and run the batch file. ‘Save the file and once again run from the command prompt. This time, itcreates the output and automatically opens Notepad with the output contents. notepad exe! c+ \users\YOURNAME\dizview.txtOUTPUT WITH VARIABLES Variables offer a more interesting way of outputting something to the screen and create a higher level of interaction between the user and the batch file. Try this example below. Create a new batch file and callit name.bat. Start with the @echo o£ command, then add the following lines: set /p nane= what is your name? echo Hello, Snane’ Note: there's a space after the question mark. Thisis to make itlook ‘neater on the screen, Save itand run the batch fie BSTEER The set /p name creates a variable called name, with the /p pat indicating that an ‘=prompt string 'stofollow. The Set command displays, sets or removes system and environmental variables. For example, while in the command prompt window enter: To view the current system variables. Note the name just created, FETED Veriables stored with Set can be called with the SWVARIABLENAME% syntax. In the batch file, we used the newiy created %éname% syntax to call upon the contents of the variable called name. Your username, For example, is stored as a variable, Try this in a batch ile echo Hello, SUSERNAMES, What axe you doing? Thisis extremely usefulif you want to create a unigue, personal batch file that automatically runs ‘when a user logs into Windows. Using the default systems variables that Windows itself creates, you can make a batch file that greets ‘each user: echo off echo Hello, echo ‘echo Thanks for logging in. ci ing at 10088 efficiency USERNAMES, ectory is located at Logged in echo The comp: SCOMPUTERNAME® echo name you" ‘Save and execute the batch file changes; you can overwrite and stil use name.batif you want. The batch file takes the current system variables and reports them ‘accordingly, depending on the user's login name and the name of the computer. Note: the double percent symbol means the percent sign willbe displayed, and isnot a variable fecho ott Alternatively, you can run the batch file and display ton the user's desktop as a text file echo Hello, 80s echo. >> cr8H0M echo Thanks £0 is operating at user. txt echo, >> c:SHONEPATH®\user. txt echo Your Hone directory is located at >> cH HHOMBPATH \user. txt echo The computer namie you're logged in to is: -RNAMES. > oz SHONEPATH®\user.txt PATHS\ueer. txt Logging in. cl 1008 efficiency. ently the network >> cr tHOMEPATHS\, echo. >> c:SHOMEPATHS\user.tat notepad c:SHOMEPATHS\useE.txt ‘The > outputs to a new file called user, while the >> adds the lines within the fieCoding with Windows 10 Batch Files Playing with Variables USING MORE VARIABLES. Here's a good example of mixing system and environmental variables with some of your own creation, along with a number of external Windows commands. PEPER creates new batch fle calledlistbat andstartitoff — IIE now, create abatch file that cisplays the contents withthe echo of£ command, Begin by clearing of any directory and postit as a text file to the user's the command prompt screen and displaying alist of the current screen. Add the Following to the list bat batch Fle: directories on the computer PEED Seve and execute the batch file. within the BED What's happening here isthe batch file asks the user ‘command prompt you can see the contents of al to enter any ofthe directories displayed in the lis it the files and directories from the root ofthe C:\ drive; and as any generated, in the form of ‘¢\directory. Providing the user enters a User under Windows has permission to see this, there's no UAC valid directory its contents are displayed as a text fil. We create elevated privileges required the view variable here along with sHOMEPATH%, to store the input andthe text ie wor bmpublicstions comFETED |: 2tvays. good idea, when creating text files forthe user to temporarily view, to clean up after yourself, There's nothing worse than having countiess, random text files cluttering up the filesystem, That being the case, lt's clear up with ae del /g view.ext del /Q list echo All files deleted. sy The additions to the batch file simply clear the ‘command prompt window (using the cls command) {and delete both the view:txt and lst.tt Files that were created by the batch file. The @ flag inthe del command meansit deletes the files without any user input or notification, The final message informs the user that the files are removed, PETEER Cevending ones) Boe ner your system is configured, — you may not get any directory information atalloramessage stating Access Denied Thisis because the UAC isblocking access to protected areas of the system, lke c\Windows (or C\Program Files. Therefore, you need to runtthe batch fleas an ‘Administrator, Click the \Windows Start button and enter CMD again. 2 ons Pons “ Playing with Variables instead of et cickng onthe Command Prompt SNPS ‘result, as you did the first time you opened it, ‘ghecickitand From te menu chose Ran as Adinrator There isa iakthat you could damage system Fes os he Adminstrator bat as ong as youre carefl and don do anything Beyond viewing Grectres,ou wil be oy. & A ® Best match Filters V7 FE Corman Prompt © Runas administrator se (Open file location - Pinto Start + Pin to taskbar BETISE DD Tisaction triggers the UAC warning message, asking you If you're sure you want to run the ‘windows command prompt withthe elevated Administrator prileges. Most ofthe time we wouldn't recommend this course of action the UAC is there to protect your system. In this case, however, click Yes, Es with the UAC active, the command prompt looks Suedo alittle different. For starters, it's now defaulting to the C\WINDOWS\system32 Folder and the top of the windows is labeled Adminstrator Torun the bath le youneed to navigate to the Btch les eco witht ed Users\USERNAME\Docimens\ Batch les. Top press the Tab key to autocomplete the directory names,E> Coding with Windows 10 Batch Files ~ Batch File Programming Teed ug-d ne (co-Lolel] e(eolpR I Me=1 NT] oaCoR- PY] itch File that help it stand out and ultimately [or teol MCA oie aR are eRe ec Ua Uceeesel due Mea Keele) Ui KecNeloM Ue Macaca ke a olen ream SEARCHING FOR FILES Here's an interesting little batch file that you can easily exter and displays the results. ind For your own use. It asks the user Fora file type to search For \We are introducing 3 couple of new commands ino the mix here but we think they're really useful Create a new batch file called seek bat and init put: Becho off els color 2 echo Please enter the type of file you want to search for (MP3, echo. Doc, JPG for example} ‘The new command inthis instance is color (Americanised spelling). Color, as you already ‘assume, changes the colour ofthe command prompt display. The Calor attributes are specified by two hex cats, the first corresponds to the background colour of the Command console and the second to the Foreground, and can be any of the following values: O=Black 8=Grey 1=Blue 9 =Light Blue 2=Green A-=Light Green 3=Aqua B= Light Aqua 4=Red C= Light Red 5=Purple D=Light Purple 6=Yellow E=Light Yellow 7=White — F = Bright White PETIEDD ow let'sextend the seek bat batch file: Becho off ele color 2 echo Please enter the type of file you want to search for (MP3, DOC, JPG for example) ‘echo. set /p ext= where /R ct\ *.Rext > found.tut notepad.exe found.txt cls color del /0 found.txt ‘Another new command, Where, looks fora specific file or directory based on the user's requirements. In this case, we have created a blank variable called ext that the user ‘anenter the filetype in, which then searches using Where and ‘dumps the results na text file called found.txt. Save and run the batch fie.CHOICE MENUS Creating a menu of choices isa classic batch Here's some code to help you understand how it all works. Rather than using a variable to process a user's response, batch files can instead use the Choice ‘command in conjunction with an rrorLevel parameter to make a ‘menu. Create anew file called menu.bat and enter the following: @echo off cls choice /M “po you want to if errorlevel 2 goto N if errorlevel 1 goto ¥ goto End: sntimue? ¥/W" Running the code produces an error as we've called Goto command without any reference toitin the file. Goto does exacty that, goes toa specific tine in the batch file Fish the fle with the Following and run it again: echo. echo goto you end ose No. Goodbye. echo. fecho You ¢ 1088 Yes. Hello tnd ‘The output from your choices cfferent depending on ‘whether you pick oF N, The:End pat simply signifies the end ofthe file (also known as EOF). Without tthe batch ileruns through each line and display the Y response even iFyou enter N; soit’ Important to remember to Follow your Goto commands (_ Batch File Programming ea” Use and a good example to help expand your batch file programming skils. Errortevls at essential variables andthe /M Sa) ‘switch of Choice allows a descriptive message string tobe displayed, Extend this menu with something new: echo off els echo. echo echo. echo echo. echo Press 1 for er\Music echo. ‘echo Press 2 for c:\Documents ‘echo. echo 3 for cr \Pictures echo echo ‘echo. echo choice /c 1234 Af errorlevel 4 goto videos evel 3 goto Pictures Af errorlevel 2 goto Documents Press Press 4 for e:\videos AE err01 FETED) Now ade the Goto sections: videos cls CD $HOMEEATH¥\ Videos echo You axe now in the Videos directory. goto End :Pictures els cD sHoMspaTHe\pictures ‘echo You are now in the Pictures directory, goto End Documents cls CD SHOMEPATH®\Documents ‘echo You goto End now in the Documents direct iMusic cls CD $HOMEPATHE\ Music echo you axe now in the Music directory. ‘goto End send when executed, the batch ile displays amenuand with teach choice the code changes directory tothe one the User entered, The SHOMEPATH% system arable wil enter the curently logged in user's Music Pictures andso directories, and not anyone elses, 7Coding with Windows 10 Batch Files Loops and Repetition COUNTERS Creating code that counts in increasing or decreasing number sets is great for demonstrating loops. With that in mind, let's look at the IF statement alittle more, alongside more variables, and introduce the Else, Timeout and eof (End of File) commands. BSED str cetissccrtacriectevcomis. EERIE) teconenstsa rough woot emonsraings fre he landagavete ano copa bete pproschwouldbet tea for oop BED Breaking it down, there’ Far then the /L saith which . . hanes arange of numbers rere raceaceeeeeeee eee Then the parameter labelled as isd a Z - ‘%%%6n to denote a number. Then eee thein (1,199) part, which es a * the statement how to count, asin Gtartnumber), 1 steps scree, ott reaces 10, totale). 99 the end umber The lineoie cored Thenest partis do, meaning DO ne, whatever command is after: counts, scrolling down the tween numbers and the Else statement continues ‘ntl the counter variable ‘equals 100 before going to the eof (End OF File, thus closing the loop, wor bmpublicstions comYou can include the pause between the numbers easily enough within the far simpler For loop by ‘adding multiple commands ater the Do For loop. The brackets and ampersand (8) separate the different commands. Ty this: for /L ¥8n in (141,99) do (echo ¥in 6 timeout /T 1 ¢nobeeak > nul) PED There ace different ways of using the For loop. In this example, the code creates 26 directories, one foreach letter ofthe alphabet, within the directory c\test which the batch file makes using the MD command: Becho off IN (ayy crdses fe Grbe Sede Le a, Vem, X/¥42) BO (nd Ce\test\$4i 51 0/PiGs Er ESTEE re of the areat time saving uses of batch filesis to create multiple, numbered files. Assume that you ‘want twenty five textiles within a directory, all numbered From 1 to 25. AFor loop muchlike the previous example does the trick: echo of for /k Stn im (1,1,2! do copy nul stn.tet PEPED you open windows Explorer, and navigate to the Batch Files directory where you're working from, you can now see 25 text files all neatly numbered, OF course, you can append the file name with something lke usert.txt and so on by altering the code to read: eecho for /L Sen in 1,2 do copy nul! Use cops can be powerful and extremely useful S126) ‘elements in a batch file. While creating 26 eectrles may not sound too elu, agin having to create 10 users on network ad assign eachone thon set of anique directories Ths where a batch fle saves an mmense armour of ie. BEGET Should you ever get stuck when using the various commands within abateh fie, drop into the command prampt and enter the command fallowed by a question ‘switch. For example, for /?orif 2. You get an on-screen help file etaling the commands use. For easier reading, pipe ito atext fle: for /2 > forbelpCoding with Windows 10 Batch Files Creating a Batch File Game Based on what you've looked at so far with batch files, you can Pode VACe A RT aR Cel ea) Tuy eeode-lel late Role alee eee Meee ela ere el ee inte) edit and make your own. Make up your own questions but how about also including an introductory or loading screen? Make your loading screen ina separate batch file and save tas screens.bat (for example). Then, from the main game batch ile, you can load it at the beginning ofthe Fle with the ‘call command followed by colour to reset the game's colours: echo off Call screens.bat color set /a scorend set /a question=0 fet /p names What is your name? wor bmpublicstions com Gecko off cis start, set /a score=0 t/a question=0 ‘set /p nane= What is your name? cle echo. echo Sttistisstansnteenneunstaetinseatsnnennntintisatens echo. echo Welcome tnamet to the super-cool trivia gane. echo. ‘echo Press 1 to get started echo. fecho Press 2 for instructions echo. echo Press Q to quit echo. echo. Srsirerneeressnsarennesinetiesintanrnnraanesnesteey, choice /c 129 if errorlevel 3 goto :eof Af errorlevel 2 goto Instructions if errorlevel 1 goto Gane cls echo. Ccho Sttistisstntatsnsneanenastsntentene echo. ‘echo The instructions are simple, Anewer the ‘questions correctly. echo. echo. Srsuresvesineanrenesnvesnesisetnestet® pause cle goto menu Lf Squestiont ==5 (goto end) else (echo you are on question tquestiont) echo, echo get ready for the question. echo. timeout /T 5 /nobreak > nul Lf Aquestiont ==5 (goto end) else (goto tquestion\) a cls echo. echo Sttistisstensnsneanensetante echo.‘echo Your current score is tscoret ‘echo. echo sttestensentensensennennnsnns ‘echo. ‘echo. ‘echo Question ‘question’. ‘echo. ‘echo Which of the following version of Windows is the best? ‘echo. fecho A. Windows 10 ‘echo. ‘echo B. Windows ME ‘echo. ‘echo C. Windows Vista ‘echo. choice /C abe Af errorlevel 3 goto wrong Af errorlevel 2 goto wrong Af ezrorlevel 1 goto correct 2 els ‘echo. (echo. #ersceresanranennrannennestets ‘echo. ‘echo Your current score is tscoret ‘echo. (Scho. setssveseentensansennaneasente ‘echo. ‘echo. ‘echo Question *question®. ‘echo. ‘echo Which of the following version of Windows is the ‘most stable? ‘echo. ‘echo A. Rindows 10 ‘echo. ‘echo B. Windows 95 ‘echo. fecho C. Windows ME ‘echo. choice /c abe Af errorlevel 3 goto wrong Af errorlevel 2 goto wrong Af errorlevel 1 goto correct a cis ‘echo. echo sttestensentennenennannnanns ‘echo. ‘echo Your current score is tscoret ‘echo. echo. semmeenesanranenneannennesants, ‘echo. ‘echo. ‘echo Question #question’. ‘echo. ‘echo Which of the following Windows version is the latest? ‘echo. ‘echo A. Windows 10 ‘echo. ‘echo B. Windows 98 ‘echo. ‘echo C. Windows 7 ‘echo. choice /C abe Creating a Batch File Game Ea” Af errorlevel 3 goto wrong Af exrorlevel 2 goto wrong Af errorlevel 1 goto correct Ey cls echo. cho setneavasvesesneennaneatnates echo. echo Your current score is tcoret echo. echo *etvesiaatensnaraneensennate echo. echo. fecho Question tquestion’. echo. echo Which of the following Windows uses Dizectx 127 echo. echo A. Windows 10 echo. fecho B, Windows 3.12 echo. echo C. Windows xP echo. choice /c abe Af ezrorlevel 3 goto wrong Af errorlevel 2 goto wrong Af errorlevel 1 goto correct ‘Wrong cle echo shenvesnaevasaneee echo. fecho WRONG!!! echo. echo shetveevasransnees set /a score=tscoret-1 pause goto :game seorzect cls chp srsavesneeressnesa echo. fecho CORRECT. YIPEE! echo. cho shenvesvaevasaneee tt /a score=tscoret#] pause goto sgane fend, els cho thetveenastensnnraneensennate echo. fecho Well done, ‘name’, you have answered all the questions echo. echo And your final score is.... echo. echo tscoret echo. echo titeveeiesteesnnrensensensenns choice /M “play again? ¥/N" Af errorlevel 2 goto :eof Af errorlevel 1 goto startRA LT rs ee en aN Up mB | dt -zA 4 4rd?on Linux Linux is such a versatile operating system that’s both malleable and powerful, while offering Re ee Sues which to build their skills. While all the popular Bonen Cuter eee es ence een Pome ene tater i) language, called scripting. Bash scripting on Linux can be used to create Pent een ec uetcns interact with the user, or simply work in the background based on a pre-defined schedule. Per En geen? Beenie ee SLT Peake ae RN nied tlt poi ton eee een ea ion FeyCoding on Linux Why Linux? FREE AND OPEN Linuxis a Fantastic Fit For those who want something different; the efficiency of the system, the availability of applications and its stability, are just a Few reasons why. ‘The first thing we need to address s that there i no basic operating system called Linux. Fundamentally, Linuxs the operating system keel the core component of an 0S, When talking about Linux we ‘aren Fact, referring to one of the mary distributions, or distros, thatuse the Linux kemel. No doubt you've heard of atleast one oF the current popular dlstros: Ubuntu, Linux Mint, Fedora, openSUSE, ‘Debian, Raspbian...the ist goes on, Each one ofthese distros offers the user something alle ciferent. While each has the Linux kernel at its core, they offer a different looking desktop environment, different preloaded applications, ciferent ways in which to update the system {and get more apps installed and a slightly efferent lookand feel throughout the entire system, However, atthe centre les Linux, which is why we say, Linux. Linuxis a great operating system in which to start coding. pea vee as 2 Deo fats wiv bempublicstionscom Linux works very differently to Windows or macOS. For a star's Free to download, Fre to install on as many computers as you tke, Freetouse for an unlimited amount oftime and free to upgrade ‘and extend with equally free programs and applications. This Free to use element is one of the biggest draws fr the developer. While a ‘Windows license can cost upto £100 and a Mac considerably more, ‘user, be they a developer, gamer, or someone who wants to put an ‘older computer to use, can quickly download a distro and get to work ina matter of minutes. ‘Alongside the free to use aspect comes aleve of freedom to customise ‘and mould the system to your own uses. Each ofthe distros avallable on the Internet havea certain spin, some offer increased security, fancy:looking desktop, a gaming specific spin, or something directed toward students. This extensibility makes Linux a more desirable platform to se, as you can quickly mould the system into adeveloprent base, including many different kinds of IDEs or use with Python, web development, C+, Java and so on, or even a base for online anonymity, perhapsas.a Minecrat server, media centre and much more. ‘Another remarkable advantage for those looking to learn how to code Isthat Linux comes with most ofthe popular coding environments builtin. Both Python and C++ are preinstalled in a high percentage of Linux distros, which means you can stato program almost as soon as youinstall the system and boot it up forthe Firstime Generally speaking, Linux doesn't take up as many system resources ‘as Windows or macOS, (by system resources, we mean memory, hard drive space and CPU load), as the Linux code has been streamlined andis fre from third-party ‘bloatware, which hogs those systems resources. A more efficient system, means more available resources For the coding and testing environment and the programs you will eventually create. Less resource use also means. You can use Linux on older hardware that would normally struggle, Cr even refuse to run, the latest versions oF Windows or macOS. A There are thousands of free packages £2 avaitabie For programmers under Linux. ( why Linuxr @S &. F) woe (Cdebian QP Mandriva stackware % s* Centos @v A Each distro offers something unique to the £2 userbutalthave Linuxatthe core. So rather than throwing away an old computer, ican be reused with aLinuxdistro, However it’s notall about C++, Python, or any ofthe other more popular programming languages. Using the command ine oF Linux {alsocalled the Terminal, youre ableto create Shell scripts, which are programs made up of sctpting languages and designedtorun from the command ine. They are used mainly to automate tasks or offer the user some form of input and autput fra certain operation. ‘There are many more advantages we could lst, for example, there
ai areutassien | ple. a Distributions There are numerous versions of Linux available, known as “Distributions”. Each has a Cece stale leceeLaeR-]9) oe. lea Ma CEMA Meet Melon ol deco ene RULE (elt) can get them. NAVIN Le eRe ees eee nee ers Mint began life back in 2006, as an alternative to the then, most Rete meta ma ‘Support buld, Linux Mint tooka different direction to offerthe ecetereenetrias Linux Mint has three main desktop versions available with each ‘new version ofthe core OS it releases. This may sound confusing ee eee ed SO eo oo) Phere CO iar aa uses less Fancy graphics buts more stable on a wider variety of eee era a desktop environment that is bult for speed and ultimate stability. ‘Throughout thisttle, wellbe using the Cinnamon version, Dene ne Meee Cas UBUNTU UBUNTU.COM Dee ceed ee en a ee eae cy ete Reg ta eet Seen eee un Ree eee eo toits presentation, along with some unfavourable and Cee ae nomena ecu ieee’ Seen te eee Cen ey its way back up the Linux leader board. The latest versions of the OS use the GNOME 3 desktop environment, it'simpressive although it can be alittle confusing for former Windows users Feo De ese a)
Installing Linux on aPC Eq INSTALLING LINUX ‘Once the Live Environment has booted, you will see the option to install the distro to your computer. Have a look around and when you're ready, look For the Install option on the desktop. Proving youre connected tothe nee Ft Before the instalation process begins, youte asked nar) then do so now) and you're in the Live Environment, Sa) iF the choice you made regarding the erasure of the starethe instalation roessbydoubleclcking onthe netallUnux | hard ive correct. Ths syou last chance to backout youre Bintcon onthe desktop, Other dstros il spl ther oun name, of certain you dont ind wiping everthing and starting gan with course butte process the sane chéContinve when ou'eresdy. Linux Mit, cick Continue, you need to back up your es remove the inv dlslUSB, reboot backup and star again le the instalation process very sina across Eventually youl be asked se up your nx suse ‘most Linux distros, some offer different questions SUES username and password. Enter your Name to begin dkringtheinstalaton General, the questions arent too ict, or with, then Computer Name - wih the name used to dent techn butsomesuchasnstalingUirdparysotvare..canbe onthe network Nex, choose Username, folowedby 2 good confusing ntiscase youcan cick Contin, utyoureursure, Password, Youcanckthe Login Automatically option but leave haveanhiemetconnected deve avalabletaskary questions.” the Encrypt Home Folder option or now ESTEE DD When instaling anew operating system it’s FSTEEEEDD The instalation process can be quick and there may recommended that you wipe the old 0S, replacing it bbe more questions ta answer, ort may simply start with the new When you reach this stage of the installation process, installing Linux based on your previous answers. Either way, you will ensure the ‘Erase dsk and install Linux.” option is selected. NOTE: end up being asked to Continue Testing the Live Environment, oF This will completely wipe Windows 10 from your computer; make Restarting to use the newly installed OS. |Fyou're ready to use Linu, sure you have backups of all your personal files and data. then click Restart Now. wu bdmpublcations com
ror 1 /binvvash leche Hello World! This is my first script im Linux mi echo Hetto worta! PEPTIED) You cansave thisfile, clicking File> Save, andexit_ RIM think of echo as the old BASIC Print command. It back to the Terminal. Entering 1s, will reveal the displays ether text, numbers or any variables that scriptin the older. To make any script executable, and able to ‘are stored in the system, suchas the current system date. Try this ‘un, you need to modify tspermissions, Do thiswith chmod +x -«example:echo Hella World! Today is $(date +8A). The ‘1d.sh. You need to do thiswith every scriptyou create. (date +%A) sclling the system variable that stores the current day of the week heLlow wn bimpublcations comCoding on Linux Creating Bash Scripts —Part 2 VARIABLES Just as in every other programming language a Bash script can store and call certain variables from the system, either generic ‘or user created. ESTEE 2t'sstar by creating a new script called hello sh; xed hello.sh.Initenter: #1/bin/bash, then, {echo iieL. 16.1. Save the file and exit Xed, Backin the Terminal ‘make the script executable with: chaioa +x helo, poain~j/xoojag ESTEE Asthe scriptis now executable, run t with =/ helle..sh. Now, as you probably expected a simple ‘Hello’ isdsplayed in the Terminal. However, f you then isue the ‘command witha variable, it begins to get interesting. For example, uy. /hello.eh David Fie Ett View Search Terminal Hep ww bcimpubications com The output now wilbe Helo David. Tiss because SUES Bash automatically assigns variables For the user, which are then el and passed tothe cpt So the variable now held ‘David You can change the varabe by entering something different: ./heliovsh in Fle Eat View Search Terminal Help ot paca aad You can even rename variables, Modify the hello. shscript with the following: fistnam irstname Seurnane. Putting surnane+$2, echo Hello $ each statement on anew line, Save the script and ext back into the Terminal Fle Et View Search Tools acumen Help noe eonjag potash x 1 /oin/bashCreating Bash Scripts-Part 2 Eps FERED) When yourun the script now youcan use two custom variables: ./helloveh David Hayward, Naturally change the two variables with your own name; unless you're aso called David Hayward, tthe moment we're just printing the contents, so let's expand the two-variable use alte File Edt View Search Terminal Help Hello David Hayward Let's expand thing Further. reste new cris SIEUE) called greetings. sh. Enter the scripting as below inthe screenshot savetand make Resectabe withthe chnod Command Youcansee tht tere ar Fe new addon othe serptno noo xoojag Bu eeingseh 1 poinibash echo “n lear Creat anew spt ced adaeLon: 8h sing US the same format as the hello.sh script, but changing the variable names Here we've aed festnonb and Secondurber, and uedthe echo command to output some simple arithmetic by pacing an nteger expression, eho tne is 8 ((@firstmunbereSoecondmunber) )-Save the scp and make rexectable (chmod ex addition.) Aoeain~ xo0 ag x ssstonsh (bin/bash [echo "The sum is $(($firstnunbersssecond (We've added a =i to the echo command here ‘which will eave the cursor on the same line asthe ‘question, instead of a new line. The xead command stores the Users’ input as the variables firstname and surname, to then read back later inthe last echo line. And the el the screen, ‘command clears File ok View Search Terminal Help FERED) When younow run the addition sh script we can entertwo numbers: ./addition.sh 1 2.The result will hopefully be 3, withthe Terminal displaying The sum 153 Try witha few different numbers and see what happens. ‘see also iF you can alter the script and rename it do multipiation, ‘and subtraction. Fle Est view search Terminal Help PETIT RD) 22 Final action, lets include the date variable ‘we used in the last section. Amend the last ine ofthe scrptto read: le Sfirstnane $surnane, how are you on this fine +8A) 2. The output should display the current day ofthe week, calling it Fram a system variable. Fle elt View Search Tools Documents Help goo xoojag Iu geetagnsh x 1einjbash Scho Welle sfirstnane ssurnane, how are you on this fine $(d wu mpublcatonscom
.snanet 2> /dev/natt JU 2m “soutput” 1s thenCreating Bash Scripts —Part 5 > FETTER When executed the script waitsfor input fromthe — [EJB The output from colours can, of course, be User inthis case the file extension, such as pg, mixed together, bringing different effects ‘mp4 and so on t's not very friendly though. Let's make italittle __ depending on what you want to the output to say. For example, friendlier. Add an echo, with: echo =n “Please enter the white text in a red background flashing (or blinking). Sadly the extension of the fle you're looking for: just blinking effect doesn’t work on all Terminals, so you may need before the read command, change to adifferent Terminal. ERE NSA FETTER Here's an interesting, fun kindof script using the app espeak Install speak with sudo apt-get stall eapeak, then enter thetext below into anew script called speak.sh. Asyou can seeit’s a rehash ofthe First greeting script ‘we ran, Only this tim, it uses the variables in the espeak output. peed Webrifiyooked at puting some cloursin the = BE ict torcurscrts whist ’stoolongtedga (ERB whist weceon making fancy crits, how about tle deperint the colour options here's ascrt that outputs sing Zeit to output graphical interface? what's aalable, create new soit called GSIGUSIB endenter Enter whatyousee below toa new Scrip, BRS, Make R the et se below into enecutable ad then runit.Youshould havea couple of dialogue bees appear Fellomed by anal message FEET RD While gaming in a Bash scriptisn't something that's often touched upon, itis entirely possible, albet, alittle basi. Movement-based games are diffuct, and ‘sometimes buggy, however a good text adventure, or Fighting Fantasy type game isa perfect choice For gaming inthe Terminal. giveita go, and let us know how you get on, wu bdmpublcations comCoding on Linux Command Line Quick Reference TOP 10 COMMANDS These may not be the most common commands used by everyone but they will certainly Feature frequently for many users of Linux and the command line ‘The ea command is one ofthe commands you The mv command moves a file to a different will use the most at the command linen Linux. It location or renames a file. For example allows you to change your working directory. You Jbrenames the original file to sub. my sub seit to move around within the hierarchy of your ketop moves the file ‘sub’ to your desktop file system. You can also use chdi directory but does nat renameit. You must specify anew filename to rename file, ‘The 18 command shows you the files in your The smmand changes the user andy current directory, Used with certain options it lets or group ownership ofeach given file. Fonly an you see file sizes, when Files where created and fle owner (@ user name or numeric user) is given, permissions, For example, 1s. = shows you the Files that users made the owner of each given file, an that are in your home directory the files’ group isnot change The ep command is used to make copies of Files he hind command changes the permissions on and directories. For example, ep file sub makes the files sted, Permissions are based on a fairly -apy ofthe file whose name you entered simple model You can set permissions for use, opy sub but the first file wil stl group and world and you can set whether each can exist with ts original name, read, write and or execute the file The pwd command prints the Full pathname of ‘The zm command removes (deletes) files or the current working directory (pwd stands For iectories The removal pracess uninks a filenar int working directory’). Nate that the GNOME inafilesystem from data on the storage dev terminal also displays this information int bar ofits wi ite and marks that space as usable by Future writes. In other words, removing files increases the amount of available space on your disk ‘The ellea command clears your screen iFthis Short For "make directory’, mika is used to is possible. It ooks in the environment for the create directories on ale system, iFthe speci erminal type and then inthe terminfo database directory does not already exist. For example, 0 figure out how toclearthe screen. Thisis, mkaive work creates a work directory. More than equivalent to typing Control when using ch shell tory may be specified when calling m wiv bempublicstionscomS SSW Ui, Ui Uy Ui, Us yj 3 USEFUL HELP/INFO COMMANDS. Mourne ary Sanur eet en Dene aa g eure Da eee nd oats Bock ee oceans Bits ke i we ele Cire re tama das Ore ees De aed co mes cue eas meer ets Dida eon eee fee ea eercscnt Pee etme iret rest ‘The BEERRESS command addsa new user tothe system. Similarly, the EREPEEN command adds 3 Peer ect Didone ae ed The nun ed view oF a running system. Ie can display rea ee eer) system summary information, as wel s lst home directory, you need to add the SESS i Pronetssenis bien ance ei aeeen rae Pigse arose eee tay all system information, including machine name, Serene ted et aid Pere Eta ce Peete ges Dome ear The BEGIEEER! command brings up the manual Coram nets eras Ce aa ‘operating systems version of psis slightly Ce eis Sis: ene etre The TORMENT command is especially useful Pere ae I-displaysthe introduction to User Commands, Poe etl Pieter maeaesertes forep bian file Bestel wurbmpublicatonscomand Ideas a ae ma reper F ae fy an 2012 o Aa at | pee Ce o c ra] pea vaa et a ‘iro Be epee e Pee meets) [ee [ rh § o1 Ogoge12 10 mm ht Ll et ee pee iio Lop a on ray Ph eh ee le ea Sy Ar rn |e putea A fan. At ate bo Pe a th cy ba nw oO Cir ay aa PF lie i> Code Projects and Ideas To help you on your way to becoming a better ee Ree Rc) ae and ideas that you can apply to your own code, NCE ume RU ed Cramer it) CT an Ree ey tered ete aceasta eke oe RNC u USER rE ay eee No matter where you go next in coding, whether it’s on to learning more languages, creating De EU ee Relea Fe ee RE Rec CR Te CE OU CNRTy Dee OSCE CnC Tal am So dream it, and code it. FyPlanning Your Code Knowing how to code is great, but it’s not going to get you very Far if you don’t know what it is you're supposed to be coding. Small samples of code don’t need much planning, but bigger projects do, so here are some tips on planning your code. Sn een Ee ee et as erent cere net eee eet er ey Re ee eee eis user interface for the company, or creating a set of automated asks that can be used across a number of different platforms, each Pera Peet eerie The planning stages canbe unique to the developer, unique to the ‘company for which they/re working, orthe project on which they're Ream een eeu ele eee the end product wil function, with each developer team then working Contheir element within the projec. Lone developers wil sometimes ‘go back to basics, grab paper and a pencil and start getting their ideas ‘down. The end results always the same, though, a plan of action that Be either eo PSEUDOCODE Live | RECEIVE wsetName FROM (STRING OM (STRING) KEY 1 VALID THEN KEYBOARI Line 2 BOARD ECEIVE piaNunb Line 3 IF useNante VALID OR piu Line 4 Allo aces to network Lis Cee a eet) pseudocode. t's terms used in programming circles that allows the Cee ne es Peet ar ane Penne ter ee eared i os Ree ee cae check user input For odd or even numbers will probably begin with a basicstatement of pseudocode: ‘Aprogram to allow a user to check ifthe numbers odd or even. eee cea eet! ne Tee e ctu) eee eres Pree at taking up too much valuable Petey ore ene Deere car) eared Deep ay reece ere Bee tsCee ego ey Ser eR eet ed Ce Ca ay have been removed due to being being classed as unnecessary. ‘This process willnot only trim the Fat off the code before ts even Renee ete Reo ee is fetta IF you're planning to include graphics in your project, such as a Be ame ees et tet tee ‘one that has been used since the early days of coding games—is cou ‘Super Mario Bros, launched For the Nintendo Entertainment SR at ey Prentice ts nee een Pree eete eeeenesd Eee eer paper since the sprites used then were made up of eight or sixteen peeing rns Ren ean ea eae Once the graphical planning stage is complete, it's then down to Ree er ad Creating the code that will place and animate your characters trea ee nero) detection, number of lives, and so on. With the help of some pseudocode, you could easily plan out what madules you'd use or create, the number of variables needed, and the various endgame ees cea eee a ee ee ee eee ay GET PLANNING The whole point of planningis to create something easy to follow that will help you write the code For your project. Planning isn't supposed Ree er eters er ee Ca See Se na tear ace et ee ate at) When planning, begin with smal steps. Coding a Hangman game, For Seon er ce or et at Ser er eet) ea ur eater ee Seen se Sa eee Once you're used to planning itl come naturally, and you'l find teen esr ee pee ener et cee eed ere Pseudocode Actual Python code ‘grade = "A" Sf score >= 80: ‘grade = "5 Sf score grade ree eee eed Preerereny Writing pseudocode will help grace = "REMC tees cyBSP) Code Projects and Ic Finding Resources MUN aTeo Keo AA Heel ela Rye ceolt ne Note Reno Loe! Internet, so Finding extra help here and there isn’t too much of a problem. However, Finding good Python resources can be, so here are some ideas for you to try. ‘You wil reach a point in your Python coding experience when you need to rely ‘on some extemal resources tohelp you through sticky patch in your project ern ge eed the internet, but not al of them are any good. Ifyou spend ay time looking Reet ce totes See eet eens ‘That's one of the main issues with resources For Python, With the language being twenty-nine years old, and many different versions under the bridge, Pere eet rote ear een ee ee eee Cte a ead Fe eee ee eee some trusted Python resources that work, ort least 90% would work, with the Cee ene En ee Mtn a lea ele) |) ke Ae) One ofthe first places that’s worth turning toi: reeCodeCamp.org, This website Features a wealth of code that covers most aspects ofthe learning experience, pen eer en ea ee Python journey to new heights; with code snippets to help youaccess networking elements, miitarystyle encryption and more, and you can even gain certification through the ste Ce gee eee ey ‘covering a wide range of concepts. There's everything in here from the original Hello, word” code, through to code that will transpose a matrixor find the hash of afl. There's also an online compiler and in-depth looks into Further reading iastenioc ramet eee Esc ueed ee ee Coe caer re ng ee eee eee rc) anne ee ener ae ene eee oereaicaett ys Cen ea ea eee ee) to date, and you may find yourself having to conwert Python 2 code into Python 3. Nevertheless, you do come across some gems from time to time, especially xyoulook up the Pygame examples that users have uploaded, We recommend the Ce eee Ne ens EySTRONG GOOGLE-FU See rs ao Cr en ee ery etna Tee rena een) Dey ck eggs, but effective searching ogo aoa how to engineer sprites moving from one side ofthe screen ae te eee iey eee rete ee aren Finding Resources ww bdmpublcatons comWHAT IS BERG Laeen ee cd providing you various content: LC Coe a a ae ee ee ee CCS eM Co [ooo Unlimited satisfaction one low price Cheap constant access to piping hot media Protect your downloadings from Big brother Safer, than torrent-trackers 18 years of seamless operation and our users' satisfaction PRE to Brand new content elt et) AvaxHome - Your End Place We have everything for all of your needs. Just open https://avxlive.icuCreating a Loading Screen IF you're looking to add a little something extra to your Python code, then consider including a loading screen. The loading screen is a short introduction, or piece of art, [ape] er=]0) 91-10 OK MaMa TN OCA meer m Back n the 80s, in the &bit Deu Peco od Cees Pa ea aL een icc eta eee then proceed to colour Pesce ar) ener Petrie eset the screen, i ete etd Peer anid Cee De eee et aac aloe ee een eee ec) ete ne etc Seer oo) introduction to the program that's aboutto be run, Re eg a) Soeur eure ye Python content. Either just for Fun, orto add alittlefetro-themey spice tothe mix. Seis Creating a loading screen in Python is remharkaBly easy, You have eo es een i Ea) display an image, followed by a brief pause, beforastarting your Guero Cetin ce Pearse eee eo Py eres FE eae tc cacy online, or use an image to ASCII Art converter to fransform any De Cea eg Ceca Pre ecet ot gi eirant air? THE CODE eee Cre neh def loading screen (seconds| =") se eevesinteceera! potatoes en Eiasteleap (eos) fain Coss. Star! “The code s quite simple: import the OS and Time modules and then create a Python Function called loading. screen with a cr Pea a oem an t dS 9 ASCIlart as read-only and create af loop that'll read the text Se ei Ree rag prmmvermrrete serene ert | eee Te Deg rian Pitas reer Tekt car mrerem ering SPORE ee eer a eta poe tes cafes) Seer eee) EyEe eee eet ret ety se frererer tt erste ete Celeg ere Coc ee merce eee) poco LOADING... errs aaa Another Favourite introduction screens that of ysimple loading Pi oer ter cnet ese Rc some characters, and a percentage of the progfam loaded: While itmay not take long for your Python code to dad, the effecteaw be interesting Gee Neg Cn rene et ean aac joading baz (10) NT aut ‘A good example of using loading screen, ASCI art eer eon Peis re tere cca Cee eer ers ee hee aS Imagine coming across a dragon, in game, and displaying its representation as ASCII You can then load up the image lines, one-by-one, and continue with eee tees ore ir Oren teeter Seta “The code works in much the same way as the previous, except, Cee tae are ea eed that prints Loading... Followed by an animation of sorts along with 2 Pe eae er ry the new results.’ simple, yes, but quit effectve'inits desion. COMBINING THE TWO How about combining the two elements we've looked at? Let's begin with a Loading... progress bar, followed by the loading screen. After that, you can include your own code and continue Perec Hsaaing) + "> + ste percent) +0) 05. system(‘cls’ if os nane == ‘nt’ else eee print ("\nYour code begins here...”) ou can, of course pul those Functions up wherever and whenever Peet ieee ena beginning. Regfemiiprtolhave the ASCUtext file in the same Folder Bio ee nd Cree eee es Saere ta as ened a eee Ey
You might also like
Batch File Programming
PDF
100% (28)
Batch File Programming
155 pages
Albert Einstein
PDF
No ratings yet
Albert Einstein
33 pages
Coding Tricks and Tips - Coding and Programming
PDF
No ratings yet
Coding Tricks and Tips - Coding and Programming
78 pages
Murach's MySQL 2012 Practica
PDF
100% (5)
Murach's MySQL 2012 Practica
608 pages
Conquer The Command Line
PDF
No ratings yet
Conquer The Command Line
56 pages
The Essential Coding Manual November 2019
PDF
No ratings yet
The Essential Coding Manual November 2019
198 pages
Batch Windows
PDF
100% (1)
Batch Windows
27 pages
Batch File Programming
PDF
100% (2)
Batch File Programming
156 pages
Alan R. Feuer - The C Puzzle Book-Addison-Wesley Professional (1998) PDF
PDF
No ratings yet
Alan R. Feuer - The C Puzzle Book-Addison-Wesley Professional (1998) PDF
187 pages
Selecting Statistical Tools
PDF
100% (1)
Selecting Statistical Tools
33 pages
Java 3 - Object-Oriented Programming
PDF
100% (1)
Java 3 - Object-Oriented Programming
174 pages
Batch Files
PDF
No ratings yet
Batch Files
98 pages
Batch Programming Basics Part-1
PDF
100% (1)
Batch Programming Basics Part-1
34 pages
Leonardo Roars For Your Attention-Fedora 11 Reviewed
PDF
100% (1)
Leonardo Roars For Your Attention-Fedora 11 Reviewed
116 pages
Coding and Programming Tricks and Tips Ed19 2024 Freemagazines Top
PDF
No ratings yet
Coding and Programming Tricks and Tips Ed19 2024 Freemagazines Top
76 pages
Creating Batch Files
PDF
No ratings yet
Creating Batch Files
8 pages
PC Intern - Encyclopedia of System Programming PDF
PDF
No ratings yet
PC Intern - Encyclopedia of System Programming PDF
1,009 pages
Epidemic Modelling
PDF
100% (3)
Epidemic Modelling
75 pages
Unix para Mac
PDF
No ratings yet
Unix para Mac
356 pages
Cryptology With Cryptool: 1.4.30 Beta03
PDF
No ratings yet
Cryptology With Cryptool: 1.4.30 Beta03
106 pages
How To Create and View Batch Files (BAT) On Windows 11 - Guiding Tech
PDF
No ratings yet
How To Create and View Batch Files (BAT) On Windows 11 - Guiding Tech
23 pages
Lars Vogel, Alex Blewitt - Distributed Version Control With Git - Mastering The Git Command Line - Third Edition (2014, Lars Vogel)
PDF
No ratings yet
Lars Vogel, Alex Blewitt - Distributed Version Control With Git - Mastering The Git Command Line - Third Edition (2014, Lars Vogel)
409 pages
Python Astronomy
PDF
0% (1)
Python Astronomy
44 pages
The Complete Coding Manual - 5th Edition, 2020
PDF
No ratings yet
The Complete Coding Manual - 5th Edition, 2020
195 pages
Lecture Notes: Chapter 1: Introduction To Macroeconomics by J. Bradford DeLong
PDF
No ratings yet
Lecture Notes: Chapter 1: Introduction To Macroeconomics by J. Bradford DeLong
13 pages
Book of Nero 7 CD and DVD Burning Made Easy PDF
PDF
No ratings yet
Book of Nero 7 CD and DVD Burning Made Easy PDF
271 pages
IGCSE ICT TeachingSuggestions PDF
PDF
100% (1)
IGCSE ICT TeachingSuggestions PDF
4 pages
TK Inter
PDF
No ratings yet
TK Inter
168 pages
Coding For Beginners
PDF
No ratings yet
Coding For Beginners
17 pages
Coding Tricks and Tips - May 2023
PDF
No ratings yet
Coding Tricks and Tips - May 2023
76 pages
Unix Commands
PDF
No ratings yet
Unix Commands
2 pages
Coding Tricks and Tips May 2022
PDF
No ratings yet
Coding Tricks and Tips May 2022
78 pages
Vim For Humans
PDF
No ratings yet
Vim For Humans
49 pages
Batch File Programing/chauhan
PDF
No ratings yet
Batch File Programing/chauhan
155 pages
Batch Files Explained
PDF
No ratings yet
Batch Files Explained
44 pages
Hello World 21
PDF
No ratings yet
Hello World 21
84 pages
Coding Programming - A Guide For Beginners 10 2021-03-07
PDF
No ratings yet
Coding Programming - A Guide For Beginners 10 2021-03-07
76 pages
Padrone Ring
PDF
100% (1)
Padrone Ring
3 pages
01 Problem Solving and Algorithm Design
PDF
No ratings yet
01 Problem Solving and Algorithm Design
27 pages
Batch Scrpting - Begineer To Core Level
PDF
No ratings yet
Batch Scrpting - Begineer To Core Level
70 pages
Python Tools Utilities
PDF
100% (1)
Python Tools Utilities
3 pages
Windows Command Line Reference
PDF
100% (2)
Windows Command Line Reference
11 pages
Perl Introduction
PDF
No ratings yet
Perl Introduction
43 pages
An Introduction To R
PDF
No ratings yet
An Introduction To R
105 pages
Awk By: Example
PDF
No ratings yet
Awk By: Example
49 pages
04 Java
PDF
No ratings yet
04 Java
32 pages
Introduction To Python
PDF
No ratings yet
Introduction To Python
38 pages
Black Dog Media - The Complete Coding Manual - 3 Ed.
PDF
No ratings yet
Black Dog Media - The Complete Coding Manual - 3 Ed.
23 pages
N (A) Science (Chem) CHP 7b Writing Chemical Equations
PDF
No ratings yet
N (A) Science (Chem) CHP 7b Writing Chemical Equations
13 pages
Batch Files (Scripts) in Windows
PDF
No ratings yet
Batch Files (Scripts) in Windows
13 pages
Advantages and Disadvantages of Linux - Renewablepcs PDF
PDF
No ratings yet
Advantages and Disadvantages of Linux - Renewablepcs PDF
6 pages
Coding Theory
PDF
No ratings yet
Coding Theory
17 pages
Data Science Career Guide Course Guidebook
PDF
No ratings yet
Data Science Career Guide Course Guidebook
18 pages
The Command Line Interface: Network and System Administration
PDF
No ratings yet
The Command Line Interface: Network and System Administration
6 pages
ZSH Refcard
PDF
No ratings yet
ZSH Refcard
14 pages
Toy Problem List To Do in Data Science Domain
PDF
No ratings yet
Toy Problem List To Do in Data Science Domain
5 pages
Batch Files
PDF
No ratings yet
Batch Files
6 pages
Java Collections: // Declare The List Concrete Type Is Arraylist
PDF
No ratings yet
Java Collections: // Declare The List Concrete Type Is Arraylist
4 pages
How Do I Learn Statistics For Data Science - Quora
PDF
No ratings yet
How Do I Learn Statistics For Data Science - Quora
4 pages
Learn How To Code (Life Hacker)
PDF
No ratings yet
Learn How To Code (Life Hacker)
22 pages