Curiosity, learning and homework help
28/03/2024
Sign upLog in
Language: FR | ENG

NEWSLETTER

:

MEMBERS

Come to discuss on the forum!
 FAST and FREE signup. 
😀 Access to discussion forums 😀
Help for HOMEWORKS, support in COMPUTER SCIENCE, help for learning FRENCH and ENGLISH, discussion on your INTERESTS and HOBBIES...

Following numerous requests, a new forum on PIPENET Vision has been created!

Looking for an English version of this section?

This section is in French because the contents are in French. If you prefer the English version of this section, click on the link below.
However, the contents in the French and the English sections are not necessarily the same!
Contents for mathematics in English


Quelques fonctions mathématiques en Python 2.x
En Python 2.x, pour pouvoir utiliser les fonctions mathématiques, il faut d'abord importer la bibliothèque math de Python avec la commande suivante :
import math

Ensuite, toutes les fonctions de la bibliothèque math deviennent disponibles.

    Exemple :
      >> import math
      >> math.cos(math.pi)

      Cette succession d'instructions renvoie la valeur de \(cos(\pi)\), soit -1.

Voici une liste non exhaustive de fonctions disponibles dans la bibliothèque math de Python :

  • Pour calculer le logarithme d'un nombre (logarithme naturel en base \(e\)) : \(\ln(x)\)
  • math.log(x)

  • Pour calculer l'exponentielle d'un nombre : \(e^x\) (ou \(\exp(x)\))
  • math.exp(x)

  • Pour calculer la racine carrée d'un nombre : \(\sqrt{x}\)
  • math.sqrt(x)

  • Pour calculer le cosinus d'un nombre : \(\cos(x)\)
  • math.cos(x)

  • Pour calculer le sinus d'un nombre : \(\sin(x)\)
  • math.sin(x)

  • Pour calculer la tangente d'un nombre : \(tan(x)\)
  • math.tan(x)

  • Pour utiliser le nombre pi : \(\pi\)
  • math.pi

  • Pour calculer la puissance d'un nombre : \(x^y\)
  • math.pow(x,y)

  • Pour récupérer l'entier inférieur le plus proche d'un nombre (la partie entière) : le plus grand entier plus petit ou égal à x
  • math.floor(x)

  • Pour récupérer l'entier supérieur le plus proche d'un nombre : le plus petit entier plus grand ou égal à x
  • math.ceil(x)

  • Pour calculer la valeur absolue d'un nombre : \(\lvert x \rvert\)
  • math.fabs(x)

  • Pour calculer la factorielle d'un entier : \(x!\)
  • math.factorial(x)

Si vous avez des commentaires ou des questions sur la bibliothèque math de Python 2.x, vous pouvez venir en discuter sur le forum : Forums de discussion.
Share this page on social media:
Quick comments
• Seb [01/08/2021 at 04:51:59]
Cette fiche est bien. Cependant, ça serait cool que vous ajoutiez plus de fonctions. 😄
• BlueGirl24 (registered member) [30/07/2021 at 18:02:30]
Merci pour cette fiche très utile! 🙂

• Message from Admin:
Merci pour ton message. 😉

Use of cookies on this website:
- If you are not a member of this website, no cookie is intentionally stored on your computer.
- If you are a member of this website, cookies are only used to keep your connection after each visit. This option can be deactivated at will in your profile and is deactivated by default.
- No other information is stored or retrieved without your knowledge, neither your personal information nor any other whatsoever. If in doubt, do not hesitate to contact the administrator of this website .
- Even this information banner does not use cookies and will therefore be displayed constantly on each visit on all pages of the website.