Python Tutorial #1

Here are some of the points which are important to me.

Regular expressions:

.*? means “match zero or more characters but as little as possible“. It is called a non-greedy match.

.* means almost the same except that as much as possible is matched (greedy match).

Examples:

  • Using f.*?a to match foo bar baz results in foo ba (stops after first a)
  • Using f.*a to match foo bar baz results in foo bar ba (stops after last a)

In Python regular expression, greedy means as much as possible.

Numeric Operator:

integer division,  a//b

float division,  a/b

Split Function: Separate two inputs with space by split function

i, c = input().split()

Difference between lists and tuples in python?

We can use tuples as

  1. keys in dictionaries
  2. elements of sets

whereas lists can not.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s