Python – Random values
In this post, we will see how to generate random values in Python. GENERATING INT NUMBERS GENERATING FLOAT NUMBERS USING SEED TO HAVE THE SAME RANDOM VALUES USING RANDOM TO GET ITEMS FROM A LIST SHUFFLING A LIST
In this post, we will see how to generate random values in Python. GENERATING INT NUMBERS GENERATING FLOAT NUMBERS USING SEED TO HAVE THE SAME RANDOM VALUES USING RANDOM TO GET ITEMS FROM A LIST SHUFFLING A LIST
In this post, we will see how to manage a string in Python. SLICING FROM STRING TO LIST AND VICE VERSA COUNT AND FIND LJUST, RJUST, STRIP, LSTRP AND RSTRIP
In this post, we will see how to create, read and write an Excel file using the module openpyxl. First of all, we need to install the module, using the command: Then, we create an Excel file called TestExcel.xlsx, so defined: HOW TO READ AND WRITE AN EXCEL FILEWe create a file called main.py where… Read More »
In this post, we will see some code snippets that can help us to manage date in Python. HOW TO CONVERT A STRING IN A DATEIn this code, we will see how to convert a string in a date: If we run the code, this will be the result: HOW TO GET TODAY DATEIn this… Read More »
Logging is a very important part in the software development because, it can help us to find bugs in our code and it is very helpful in case of application crashing.To be honest, it is a common practice using, especially during the development, the command Print() in order to find bugs, instead to use Logging.But… Read More »
In this post, we will see how to manage Try/Except in Python. Just to remember what try/except is: Try/Except is a statement marks a block of statements to try and specifies a response should an exception be thrown.In detail, in Try/Except we have three blocks:Try, used to test a block of code for errors.Except, used… Read More »
In this post, we will see what Eval() is and how we can use it. We start creating a function that returns true if a given inequality expression is correct and false otherwise. Examples: test_signs(“3 < 7 <11”) return Truetest_signs(“13 > 44 > 33 > 1”) return Falsetest_signs(“1 < 2 < 6 < 9 >… Read More »
In this post, we will see how to resolve FizzBuzz using Python.We will create a function that takes a number as input and it will return “Fizz“, “Buzz” or “FizzBuzz“.The rules are: EXAMPLES:Fizz_buzz(3) -> “Fizz”Fizz_buzz(5) -> “Buzz”Fizz_buzz(15) -> “FizzBuzz”Fizz_buzz(4) -> “4” SOLUTION:We open Visual Studio Code and we create a file called FizzBuzz: [FIZZBUZZ.PY] If we… Read More »
In this post, we will see how to connect a Python application with the MySQL Db called “DbManagerUser”, created in the post: MySQL – How to create a DB. First of all, in order to install the MySQL connector for Python, we run the command pip install mysql-connector-python. Then, we open Visual Studio Code and… Read More »