Description:

The purpose of this lab is to teach students how to create a program where it ask an user to insert a response. In this lab conditionals, control flow, statements, and build-in functions. The creation of this program can be related to an application on your smart phone, or computer where the program ask you for anything and you insert a response where the program later returns an answer or value. If you are using Python version 3 you should type “input” instead of “raw_input” as shown in the steps. In step one we create a variable called “original” and set it equal to ‘”raw_input(“Enter a word”)”‘. This allow us to display a question or statement to a user or the console. In step two we implement two conditional statement, the “if” and “else” which both build-in functions. In the :if:” statement, we type “len(original) > 0” then press enter, indent the next code which is “print original” and type “else:” press enter, indent, and type “print empty”. This let the program to determine if there were any word typed and if the statement is true it will display the word that was typed in the console or it would display “empty” if the “if” statement is false which indicates that no word was typed. The “len()” function allows python to determine the length of the variable inserted.  In step three we include the logical operator “and”, and also a build-in function that allows the program to determine if the word typed contains letter only. The if statement should look like step#3 shows. In step 4 we created another variable called “pyg” which is set to ‘ay’. In step 5 we set two new variables and values which they are “word = original.lower()” and “first = word[0]”. The “.lowe()” function allows python to set the variable in lower case and the [0] takes the first letter of the value of that variable. In python, the position of the word starts in 0 instead of 1. In step 6 we set another variable which concatenate the variables “word”, “first” and “pyg”. This lets the combination of all the variable into one. In step 7 we finish our code by setting “new_word” to “new_word[1:]” which allow us to display the word from the second letter to the last one. Step 8 shows the testing of the code.

Step #1:

 

 

 

Step #2:

 

 

 

Step #3:

 

 

 

Step #4:

 

 

 

Step #5:

 

 

 

Step #6:

 

 

 

Step #7:

 

 

 

Step #8: