Day 4: 100 Days of Code

Day 4: 100 Days of Code

Python

Day 4 was about:

Randomization

There is python module to generate random numbers or sequences. We can use that for different games e.g., Heads or Tails, Banker Roulette - Who will pay the bill? and Treasure Map also for other purposes

import random

random_integer = random.randint(1,10)
print(random_integer)

Lists

Lists are data structure used to store grouped data in order. The indexing of lists starts from 0 in python lists. We can apply different methods on list, read the python lists documentation that explain different methods of list.

IndexError

This is the error we usually see while working with python lists. It is because if exceed the limit of list or try to access an item from an index that actually do not exist in the list then we see this error.

Nested List

When we have lists inside list we call it as nested lists. This can be use when for instance we have two groups of elements and they are some how related to each other than we can put both groups of list into one list.

list = [["Apple", "Banana", "Orange "],["Onion", "Garlic","Spinach"]]

Exercises

We have done 3 exercises on day 4

  1. Heads or Tails
  2. Banker Roulette - Who will pay the bill?
  3. Treasure Map

Head over to my GitHub repository to see their codes.

Project

Rock, Paper, Scissor game is built. We plays with computer. Randomization is applied on behalf of computer to chose new number every time we play. For the images of rock, paper and scissor we used ASCII ART images.

The project is in GitHub repository.