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.
Tuesday, 11 November 2014
(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.
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.
adding letters to lists
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
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.
And this is the output.
Wednesday, 1 October 2014
Tuples
index number is the number of the position of the string in the list. In this example, winter summer spring and fall are the strings, and their index number (position) starts from 0.
I then added tuples to my 8 ball program to reduce the line codes.
I then added tuples to my 8 ball program to reduce the line codes.
Monday, 29 September 2014
Saturday, 20 September 2014
While loop counting to 8
21/09/14
These are three different ways of programming Python to count to 8, using <,>, and not equal to ( !=).
These are three different ways of programming Python to count to 8, using <,>, and not equal to ( !=).
Wednesday, 17 September 2014
while loop restart
17/09/14
In this program, the while loop will keep restarting as long as "y" is inputted. If anything else is inputted, the program will exit the while loop.
In this program, the for loop will print a command for each item in the list, in this example it is the list
In this program, the while loop will keep restarting as long as "y" is inputted. If anything else is inputted, the program will exit the while loop.
In this program, the for loop will print a command for each item in the list, in this example it is the list
Monday, 15 September 2014
while loop
16/09/14
In this code, the program is in a while loop, such that it will print the number of line, then the actual line, until "lines" is no longer <5 .
In this while loop, it does the same thing only it doesn't print the number of the line, and it goes up to 50 lines, and also a new line for each print.
In this code, the program is in a while loop, such that it will print the number of line, then the actual line, until "lines" is no longer <5 .
In this while loop, it does the same thing only it doesn't print the number of the line, and it goes up to 50 lines, and also a new line for each print.
Wednesday, 10 September 2014
calculations and assigning values to variabels
10/09/14
In this lesson I learned the functions of \n (which starts a new line on IDLE), as well as the basic maths part of the python, such as finding the remainder of a division, rounding and importing a math function; ceil. Importing math functions such as square root or cos will also work. We also found the difference between python 2.X and 3.X (this is 3.X).
14/9/14
In this lesson I learned how to assign a value to a variable, as well as telling the program to print the new values. I also learned how the and -= would re-assign "a" as "a - b" (also works for the addition).
Subscribe to:
Posts (Atom)





































.jpg)
