Category Archives: Python

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 »

Python – How to create a RESTful service

By | 14/01/2020

In this post, we will see how to create a RESTful service for handling data of some Dogs, with Python and Flask. First of all, what Flask is?From Wikipedia:“Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries.It has no database abstraction layer, form validation, or any… Read More »

Python – Set

By | 30/09/2019

Set is an unordered collection of comma separated unique elements inside curly braces. The order of element is undefined and it is possible to add and delete elements and, it is possible to perform standard operations on sets like union, intersection and difference.In this post, we will see how to manage Set in Python. CREATE… Read More »