Introduction to Control Structures and Data Types Lab
The simple programs you have written so far simply execute one instruction after another. The sequence is always the same. However, the power of programming is released when your program can decide which commands to execute based on conditions. Logic is used to make the decisions. That’s powerful. In addition, we have to deal with the fact that com...
Already have an account? Sign In »

The simple programs you have written so far simply execute one instruction after another. The sequence is always the same. However, the power of programming is released when your program can decide which commands to execute based on conditions. Logic is used to make the decisions. That’s powerful.
In addition, we have to deal with the fact that computers only know 0’s and 1’s, otherwise known as the binary number system. Somehow, some way, our programs need to put data in terms of 0’s and 1’s. For example, when you enter your name at a prompt, or even in a text box on a web page form, those letters of the alphabet need to be translated into binary for the computer to store or otherwise process the data. Beyond letters, special characters, and so forth, fractional numbers need to be translated into 1’s and 0’s. That is, numbers with decimal points need to be represented in memory as simple 0’s and 1’s. You don’t need to be an expert on the binary number system in order to write Python programs because Python does the heavy lifting for you through data types. You need to understand data types.
In this lab, you will explore several different approaches, including the Python command, directly using the shebang, absolute paths, and relative paths. You will also redirect standard input (stdin) and standard output (stdout) to and from your program and disk files, which really helps harness the power of CLI programs. As before, the focus will be on debugging and problem solving.
Everybody wants the respect of his or her peers. Programmers earn their peers’ respect by following best practices. That means neat, clean, readable code that gets the job done and is easy to understand. A good place to start with developing programming best practices is the choice of variable names. Well-chosen names go a long way towards making your code understandable.
We’ll explore all of these things in this lab.