Python Program to Swap Two Variables

In this example, you will learn to swap two variables by using a temporary variable and, without using temporary variable. In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.

[mai mult...]

Get Current Date and Time using Python

To get both current date and time datetime.now() function of datetime module is used. This function returns the current local date and time.

Syntax: datetime.now(tz)

Parameters:
tz : Specified time zone of which current time and date is required. (Uses Greenwich Meridian time by default.)

Returns : Returns the current date and time in time format.

[mai mult...]

Categorize Password as Strong or Weak using Regex in Python

Given a password, we have to categorize it as a strong or weak one. There are some checks that need to be met to be a strong password. For a weak password, we need to return the reason for it to be weak.

Conditions to be fulfilled are:

  • Minimum 9 characters and maximum 20 characters.
  • Cannot be a newline or a space
  • There should not be three or more repeating characters in a row.
  • The same string pattern(minimum of two character length) should not be repeating.
[mai mult...]