Posts

Showing posts with the label #pythonlearning

Swapping Two Variables in Python

Image
  Swap two variables python example code: a = 5 b = 10 a, b = b, a print ( "a:"  , a) print ( "b:", b)

Lambda Functions in Python

Image
  Lambda Functions Example Code add = lambda x, y: x + y result = add(3, 5) print("Result of addition:", result)

Calculate the Area of a Circle with PYTHON

Image
  Calculate the Area of a Circle import math radius = float ( input ( "Enter the radius of the circle: " )) area = math.pi * (radius ** 2 ) print ( "Area of the circle:" , area)

PASSWORD GENERATOR PYTHON BOT

Image
  PASSWORD GENERATOR BOT of PYTHON import random import string def generate_password (length): characters = string.ascii_letters + string.digits + string.punctuation password = '' .join( random. Choice (characters) for _ in range (length)) return password # Example usage to generate a 12-character password password = generate_password( 12 ) print (password) YOU CAN ALSO USE THIS ONE import random import string def generate_password(length, uppercase, lowercase, numbers, special):     # Generates a password with customizable options for length, complexity, and character types.     # Define the character sets for each type of character     character_sets = []     if uppercase:         character_sets.append(string.ascii_uppercase)     if lowercase:         character_sets.append(string.ascii_lowercase)     if numbers:         character_sets.append(string.d...