Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 42 of 81

How to identify and print all the perfect numbers in some closed interval [ 2, n ] using Python?

Chandu yadav
Chandu yadav
Updated on 05-Mar-2020 2K+ Views

A perfect number is a positive integer that is equal to the sum of its proper divisors. The smallest perfect number is 6, which is the sum of 1, 2, and 3.You can find perfect numbers within a given range by testing each number for the given condition in the given range. exampledef print_perfect_nums(start, end):    for i in range(start, end + 1):    sum1 = 0    for x in range(1, i):       # Check if a divisor, if it is, add to sum       if(i % x == 0):          sum1 = sum1 + x          if (sum1 == i):             print(i) print_perfect_nums(1, 300)OutputThis will give the output6 28

Read More

How to Find ASCII Value of Character using Python?

Chandu yadav
Chandu yadav
Updated on 05-Mar-2020 261 Views

The ord function in python gives the ordinal value of a character(ASCII). You can use this function to find the ascii codes as followsExamples = "Hello" for c in s:    print(ord(c))OutputThis will give the output72 101 108 108 111

Read More

How to check for redundant combinations in a Python dictionary?

Chandu yadav
Chandu yadav
Updated on 05-Mar-2020 200 Views

There will never be redundant combinations in a Python dictionary because it is a hashmap. This means that each key will have exactly one associated value with it. This value can be a list or another dict though. So if you try to add a duplicate key likeExamplea = {'foo': 42, 'bar': 55} a['foo'] = 100 print(a)OutputThis will give the output{'foo': 100, 'bar': 55}If you really want multiple values for a single key, then you should probably use a list to be associated with the key and add values to that list.

Read More

What are Python coding standards/best practices?

Chandu yadav
Chandu yadav
Updated on 05-Mar-2020 707 Views

You can use the PEP8 guide as a holy grail. Almost all python world uses this guide to write clean understandable and standard python code. This is available as an extension as a linter for all modern text editors. You can check it out at  http://www.python.org/dev/peps/pep-0008/Properly Structure your folders. All projects need proper structuring. This helps organize code better. Python has an opinionated folder structure that you should use.README.rst LICENSE setup.py requirements.txt sample/__init__.py sample/core.py sample/helpers.py docs/conf.py docs/index.rst tests/test_basic.py tests/test_advanced.pyUse doctests. The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to ...

Read More

Usage of :link pseudo-class in CSS

Chandu yadav
Chandu yadav
Updated on 04-Mar-2020 98 Views

The :link pseudo-class is used to add special style to an unvisited link. Possible values could be any color name in any valid format. Example                    a:link { color:#000000; }                                Demo Link          

Read More

CSS min-width property

Chandu yadav
Chandu yadav
Updated on 04-Mar-2020 162 Views

The min-width property is used to set the minimum width that a box can be. The value of the min-width property can be a number, a length, or a percentage.Example                            This paragraph is 100px high and min width is 400px          This paragraph is 100px high and min width is 400px              

Read More

HTML5 Canvas & z-index issue in Google Chrome

Chandu yadav
Chandu yadav
Updated on 04-Mar-2020 850 Views

When we apply z index to a canvas whose position is fixed, it stop causes chrome to render all other elements which have position:fixed properly. This only happens if canvas is greater than 256X256 px in size.Wrap both h1 and canvas with the fixed div and solves the issue −    Test Title     The following is the CSS −h1{    position: fixed; } body{    height: 1500px; } canvas{    position: fixed; z-index: -10; }

Read More

How can I use the HTML5 canvas element in IE?

Chandu yadav
Chandu yadav
Updated on 04-Mar-2020 360 Views

Use excanvas JavaScript library to use HTML5 canvas in Internet Explorer(IE).The excanvas library is an add-on, which will add the HTML5 canvas functionality to the old IE browsers (IE7-8).Firefox, Safari and Opera 9 support the canvas tag to allow 2D command-based drawing operations.ExplorerCanvas brings the same functionality to Internet Explorer. To use the HTML5 canvas element in IE, include the ExplorerCanvas tag in the same directory as your HTML files, and add the following code to your page in the head tag.

Read More

HTML5 inline video on iPhone vs iPad/Browser

Chandu yadav
Chandu yadav
Updated on 03-Mar-2020 555 Views

The allowsInlineMediaPlayback  property of a UIWebView) enables/ disables in line media playback in the iOS web browser for a native app. By default, on iPhone this is set to NO, but on iPad its set to YES. Hence, the native video player takes over the screen, thus obstructing us from playing other dynamic content simultaneously with the video Adjust this behaviour in HTML as follows − iOS10+ In iOS 10+, Apple has now enabled the attribute playsinline in all the web browsers on iOS 10. Now, play around with this easily −

Read More

How to copy the content of one HTML5 Canvas to another Canvas locally?

Chandu yadav
Chandu yadav
Updated on 03-Mar-2020 3K+ Views

The drawImage() method is used to draw image, canvas and videos on canvas. It can also draw part of image and increase or decrease the image size.ExampleLet us see an example −//context grabbed from your destination canvas ctx = destinationCanvas.getContext('2d'); //drawImage() called passing the source canvas directly dCtx.drawImage(sourceCanvas, 0, 0);In this code, firstly the image is copied from the source canvas. The sourceCanvas can be a HTMLImageElement, HTMLVideoElement, or a HTMLCanvasElement. A canvas drawing context cannot be used as a source. If a canvas drawing context is your source canvas then there is a reference to the original canvas ...

Read More
Showing 411–420 of 810 articles
« Prev 1 40 41 42 43 44 81 Next »
Advertisements