Tag Archives: Python

Python – Random values

By | 22/02/2023

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

Python – Date

By | 14/12/2022

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 »

Python – Logging

By | 23/11/2022

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 »

Python – Try/Except

By | 20/01/2021

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 »

Python – Eval

By | 04/08/2020

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 »

Python – FizzBuzz

By | 28/07/2020

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 »

Python – How to connect to MySQL

By | 05/02/2020

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 »