O GoConqr está de visual novo! Conte para nós o que você achou.

Mapa mental

Introduction to Python modules

Suja Nair Inglês

Conteúdo do mapa

Introduction to Python modules

  1. Module

    • Definition
      • Separately saved unit whose functionality can be reused at will
  2. Purpose of modules.

    • Code reusability.
  3. Importing Modules

    • Using the import statement.
      • Syntax: import module_name.
      • Example: import math.
    • Importing specific functions or classes.
      • Syntax: from module_name import function_name.
      • Example: from math import sqrt.
  4. Commonly Used Modules

    • math module
      • Purpose of math modules
        • Provide mathematical functions
      • Contants
        • pi
          • mathematical constant
          • used in geometry
          • syntax: math.pi
        • e
          • The math. e constant returns the Eular's number: 2.718281828459045
      • Functions
        • ceil()
          • Rounds a number up to the nearest integer
            • print(math.ceil(4.2)) Output: 5
            • print(math.ceil(-4.2)) Output: -4
        • sqrt()
          • Function to calculate the square root Part of the math module Returns a float
            • Access using 'math.sqrt()'
        • exp()
          • Returns e raised to the power of a given number
            • syntax: math.exp(x)
        • fabs()
          • Function to compute the absolute value
            • Returns the non-negative value
            • Example
              • math.fabs(-5) returns 5.0
              • fabs(3.2) returns 3.2
        • floor()
          • Rounds down to nearest integer
          • Example
            • floor(3.7) returns 3
            • floor(-3.7) returns -4
        • pow()
          • Computes power of a number
          • math.pow(2, 3) returns 8
        • sin()
          • Returns sine of an angle
    • random module
      • random()
        • Function to generate random numbers
          • random.random()
      • randint()
        • Function to generate random integers
          • Example: random.randint(1, 10)
      • randrange()
        • A function to generate random numbers
          • Syntax: randrange(start, stop[, step])
            • Example: result = randrange(0, 20, 5)
              • Generates 0, 5, 10, 15 (exclusive of 20).
    • statistics module
      • mean()
        • Calculates the average of numerical values
          • statistics.mean(data)
      • mode()
        • Most frequently occurring value
          • Example
            • data = [1, 2, 2, 3]
              • `statistics.mode(data)` returns `2`
      • median()
        • Median is the middle value
          • statistics.median(data)

Informações

Descrição
Mapa Mental sobre Introduction to Python modules, criado por Suja Nair em 17-05-2025.
Criado por
Suja Nair
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?