Karthikeya Boyini has Published 2382 Articles

How to convert python tuple into a two-dimensional table?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 06:10:12

1K+ Views

If you have a numeric library like numpy available, you should use the reshape method to reshape the tuple to a multidimensional array. exampleimport numpy data = numpy.array(range(1, 10)) data.reshape([3, 3]) print(data)OutputThis will give the output −array([[1, 2, 3],        [4, 5, 6],        [7, 8, 9]])ExampleIf ... Read More

How can I represent immutable vectors in Python?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 06:04:42

151 Views

You can use tuples to represent immutable vectors in Python. Tuples are immutable data structures that behave like a list but maintain order and are faster than lists. examplemyVec = (10, 15, 21) myVec[0] = 10This will produce an error as tuples can't be mutated.

How can we combine multiple print statements per line in Python?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 05:08:00

4K+ Views

You can combine multiple print statements per line using, in Python 2 and use the end argument to print function in Python 3.examplePython2.x print "Hello", print " world" Python3.x print ("Hello", end='') print (" world")OutputThis will give the output −Hello worldAnother thing you could do is put all the ... Read More

How to change the color of focused links with CSS

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 05:01:04

1K+ Views

Use the :focus class to change the color of focused links. Possible values could be any color name in any valid format.ExampleYou can try to run the following code to implement the color of the focused link −                    a:focus {             color: #0000FF          }                     This is demo link    

Usage of :first-child pseudo-class in CSS

karthikeya Boyini

karthikeya Boyini

Updated on 04-Mar-2020 12:46:22

67 Views

Use the :first-child pseudo class to add special style to an element that is the first child of some other element.ExampleYou can try to run the following code to understand the usage of :first-child pseudo class −                    div > p:first-child ... Read More

Usage of :visited pseudo-class in CSS

karthikeya Boyini

karthikeya Boyini

Updated on 04-Mar-2020 12:43:32

70 Views

The :visited pseudo-class is used to add special style to a visited link. Possible values could be any color name in any valid format. Example                    a:visited {             color: #006600          }                     Click this link    

Using CSS z-index property

karthikeya Boyini

karthikeya Boyini

Updated on 04-Mar-2020 12:37:34

185 Views

The z-index property is used along with the position property to create an effect of layers. You can specify which element should come on top and which element should come at the bottom. ExampleYou can try to run the following code to implement the z-index property −                                                     

Usage of CSS visibility:visible;

karthikeya Boyini

karthikeya Boyini

Updated on 04-Mar-2020 12:33:12

91 Views

The visibility property with value visible is used to make an element visible. You can try to implement the following code to implement the visible property − Example                    p {             visibility: hidden;          }                              This paragraph is visible.                      This paragraph won't be visible.          

What to do when an element's content might be larger than the amount of space allocated to it?

karthikeya Boyini

karthikeya Boyini

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

53 Views

Use the CSS overflow property to solve this issue of a content exceeding the allocated space. You can try to run the following code to solve the issue −Example                   .scroll{          display:block;          border: 2px ... Read More

CSS line-height property

karthikeya Boyini

karthikeya Boyini

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

120 Views

The line-height property is used to set the height of a line of text. The value of the line-height property can be a number, a length, or a percentage.Example                            This paragraph is 300 pixels wide and 100 pixels high and here line height is 50 pixels.          

Advertisements