Lakshmi Srinivas has Published 287 Articles

How to create a lambda inside a Python loop?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 05-Mar-2020 09:54:01

1K+ Views

You can create a list of lambdas in a python loop using the following syntax −Syntaxdef square(x): return lambda : x*x listOfLambdas = [square(i) for i in [1, 2, 3, 4, 5]] for f in listOfLambdas: print f()OutputThis will give the output −1 4 9 16 25You can also achieve ... Read More

How to overload python ternary operator?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 05-Mar-2020 07:38:52

362 Views

The ternary operator cannot be overloaded. Though you can wrap it up in a lambda/function and use it. For exampleresult = lambda x: 1 if x < 3 else 10 print(result(2)) print(result(1000))OutputThis will give the output −1 10

How do we compare two tuples in Python?

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 05-Mar-2020 05:57:34

6K+ Views

Tuples are compared position by position: the first item of the first tuple is compared to the first item of the second tuple; if they are not equal, this is the result of the comparison, else the second item is considered, then the third and so on. example>>> a = (1, ... Read More

What are CSS pseudo-classes

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 04-Mar-2020 12:38:10

99 Views

CSS pseudo-classes are used to add special effects to some selectors. You do not need to use JavaScript or any other script to use those effects.The most commonly used pseudo-classes are −ValueDescription:linkUse this class to add special style to an unvisited link.:visitedUse this class to add special style to a ... Read More

Usage of margin-right property with CSS

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 04-Mar-2020 12:18:39

70 Views

The margin-right specifies the right margin of an element. It can have a value in length, % or auto. You can try to run the following code to set the right margin −Example                            This is a paragraph ... Read More

CSS max-height property

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 04-Mar-2020 12:13:27

113 Views

The max-height property is used to set a maximum height that a box can be. The value of the max-height property can be a number, a length, or a percentage.Example                            This paragraph is 400px wide and max ... Read More

CSS height property

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 04-Mar-2020 12:09:06

115 Views

The height property is used to set the height of a box. They can take values of a length, a percentage, or the keyword auto. ExampleYou can try to run the following code to set height −                             This paragraph is 200pixels wide and 50 pixels high          

Set the width, line style and color properties for an outline in a single statement with CSS

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 04-Mar-2020 11:26:25

187 Views

The outline property is a shorthand property that allows you to specify values for multiple properties such as width, line style, and color of the outline.Example                            This text is having thin solid freen outline.                            This text is having thick dashed green outline.                      

Specify the top padding of an element with CSS

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 04-Mar-2020 11:12:29

87 Views

The padding-top specifies the top padding of an element. It sets the top padding of an element. This can take a value in terms of length of %.Example                            This is demo content.                      This is another demo content.          

Usage of CSS list-style property

Lakshmi Srinivas

Lakshmi Srinivas

Updated on 04-Mar-2020 11:04:31

78 Views

The list-style serves as shorthand for the preceding properties. The list-style allows you to specify all the list properties into a single expression.Example                            Table          Chair          

Advertisements