1. Background In recent days, I find there is an interesting website (https://sc.chinaz.com/yinxiao/index.html) It carries some free resume templates and sound effects resources, which are great in my production. It is will be very convenient if I can collect these resources automatically instead of manual download each of them. To solve the problem, these python […]
Python: Why you should choose pytest instead of unittest?
1. What is Pytest? The pytest framework makes it easy to write small, readable tests and can scale to support complex functional testing for applications and libraries. 2. Why do I choose pytest instead of unittest? Although both frameworks are great for performing testing in python. Firstly, pytest is fast, efficient, and easy to work […]
PYTHON: A data structure you should know—Dictionary
1. What is a dictionary data structure? You may hear about Hash Map in other programming languages. The same concept in python is called the dictionary. Dictionaries are used to store data values in key and value pairs. The advantage of the way key-value storing makes the search very fast especially compared to the way […]
PYTHON: From Random Module To The Dice Game
1. Random Module In python, the function random() can not be directly called. However, we need to import a random module and generate random numbers by calling the static method. By importing this random module, it implements pseudo-random number generators for various distributions.
PYTHON: Find narcissistic number from 100 to 1000 by loop and if-statement
1. The definiation of narcissistic number The narcissistic number is also called the pluperfect digital invariant (PPDI) or Armstrong number. A narcissistic number is an n-digit number(n>=3) whose sum of the n-th powers of the digits in each digit is equal to itself (eg: 1^3 + 5^3 + 3^3 =153).
PYTHON: Object-oriented programing
1. The core concepts of object-oriented programing Object-oriented Programming (OOP: Object-Oriented Programming) is a programming idea that treats each object as the basic unit of the program, and each object has corresponding data and functions to process the data.
PYTHON: How to calculate BMI by If statement
1. What is the BMI? The BMI is the abbreviation of the Body Mass Index (BMI). It can be used to measure leanness based on height and weight. It is also a measurement of the health condition. It is used for the statistical purposes, it analyzes the health condition of a person’s weight on people […]
PYTHON: How to get factorial by recursion
1. The concept of factorial The factorial of a positive integer is the product of all positive integers less than and equal to the number, and the factorial of 0 is 1. The factorial of a natural number n is written as n!. It is invented by Christan Kramp (1760-1826) That is, n!=1×2×3×…×n. Factorials can also be […]