Day 4 - 100 Days of Python

·

2 min read

import random

Today I learned how to use the random module in Python. One of the popular use cases is to generate a random number between two given numbers by calling random.randint(1, 10). In my opinion, this particular method is more powerful than JavaScript. In this case, we don't have to write the extra code to achieve the desired behavior.

In JavaScript, I used to do this:

// Generate a random number between 1 and 10
Math.floor((Math.random() * 10) + 1);

random.seed()

random.seed() is a fairly new concept to me. I have not fully grasped the idea yet. From what I read more on AskPython.com, it says that random.seed() is a method that will determine the result of our random generated numbers. If we do not change the value, the output will remain the same.

I guess it means that if we do not call this method, the random number generator will possibly give us very different results every time.

Practice

I have completed yet another beginner challenge from devchallenges.io. I can't wait to tackle more challenging projects! I feel so good to build projects even if it is a simple one because I can still learn a thing or two in the process. I learned how to make the text appears vertically by using two CSS rules that are:

text-orientation: mixed;
writing-mode: vertical-rl;

Result

css-rules.png