Tuesday, 11 November 2014

(Q.10) rock paper scissors

this was the final question of the assignment, where i had to create a program that plays rock paper scissors with the user. i added extra features such as a game of 'best of 5', keeping count of score and restarting.




(Q.9) heads and tails


the program will randomly choose heads or tails 50 times and print each time whether it was heads or tails. then the sum of each is returned at the end.



(Q.8) counting zeros, positive and negative numbres

this program was part of an assignment were i had to create a program that asks for 7 numbers from the user, adds up the numbers and returns the sum, as well as counting how many zeros, positive and negative numbers were entered.



keeping a running total

this program is a basic 'how to keep a running total' through a for loop.


restarting

this program is a nice experiment of a yes - no tree diagram, such that a route is taken depending on the user's input.


random card

this program generates a random card each time.


discounting

This a program that discounts a given price by a given percentage.





currency conversion

this is a program that will convert DHS, USDand GBP in three way.



adding letters to lists

 this program will add a letter to the list in any given position. I purposely left out the letter 'e' so the user can attempt the code in a practical way


counting zeros

this program takes in 5 numbers, and keeps a running total in a for loop for the number of zeros entered.



Monday, 10 November 2014

guessing game

this code generates a random number that the user has to guess.


encryption

this is a code that encrypts any given word of any length and asks for a shift key, in which each letter will shift across the alphabet by that number.


and the output...



def function

this is a code to show how you can use the def function. the def will define a function which can be recalled and used later on in the program.


And this is the output.


Counting in twos for and while loop


this program counts up to twenty in twos in a while loop and a for loop. this was the output.