How to draw a line with lineTo() in HTML5?

Daniol Thomas
Published on 22-Jan-2018 14:08:36
To draw a line in HTML, use the canvas element. With canvas, use the lineTo() method to draw a line. The lineTo() method includes x and y parameter values, which positions the line.ExampleYou can try to run the following code to draw a line with lineTo() in HTML5 −<!DOCTYPE html> ... Read More

How to draw on the canvas with JavaScript?

Krantik Chavan
Published on 22-Jan-2018 13:45:32
Drawing on the HTML canvas is to be done with JavaScript. Use the HTML DOM Method getElementById() and getContext() before drawing on the canvas.For that, follow some steps −You need to use the getElementById() method to find the canvas element.Use the getContext(), which is drawing object for the canvas. It ... Read More

What are Python OOP Basics?

Rajendra Dharmkar
Published on 24-Jan-2018 13:18:42
OOP concepts in PythonPython is an object-oriented programming language. We can easily create and use classes and objects in Python.Major object-oriented concepts of Python programming language are given below:Object ; Class;  Method;  Inheritance; Polymorphism ; Data Abstraction ; EncapsulationObjectObject is an entity that has state and behaviour. It may be ... Read More

Why to use canvas tag in HTML5?

Nishtha Thakur
Published on 22-Jan-2018 13:37:08
Specifies height of the canvas.The HTML <canvas> tag is used to draw graphics, animations, etc. using scripting. The <canvas> tag introduced in HTML5.Let’s see a simple <canvas> element with two specific attributes width and height along with all the core HTML5 attributes like id, name, and class etc.<canvas id="myCanvas" width="100" ... Read More

How to convert JSON data into a Python object?

Rajendra Dharmkar
Published on 24-Jan-2018 13:04:43
The following code converts a json object(string) into a python object(dictionary). We import the json module and use the json.loads() method to do this.Exampleimport json json_string = '{"name":"Sonali", "age": 21, "designation":" Software developer"}' print type (json_string) def func(strng):     a =json.loads(strng)     print type(a)     print a ... Read More

How to use step attribute in HTML?

Smita Kapse
Published on 22-Jan-2018 13:14:51
The HTML input type step attribute sets the legal number intervals. Steps are number steps like 0, 4, 8, 12, 16, etc. The step attribute can be used together with the max and min attributes to create a range of legal values.ExampleYou can try to run the following code to ... Read More

How to use the required attribute in HTML?

Rishi Rathor
Published on 23-Jan-2018 09:36:10
The required attribute in HTML is used o specify that the element should be filled before the form is submitted. If the field isn’t filled and the submit button is clicked, an error generates, which fails form submission. The error will be “Please fill out this field”.The required attribute can ... Read More

How we can convert Python objects into JSON objects?

Rajendra Dharmkar
Published on 24-Jan-2018 12:33:46
Suppose we have a list object a = [1,2,3]. We convert a python object into a JSON object by importing json module and using the method json.dumps() as follows.>>> a = [1,2,3] >>> import json >>> json.dumps(a) '[1, 2, 3]'The JSON object we got is '[1, 2, 3]'

How to use placeholder attribute in HTML?

Anvi Jain
Published on 22-Jan-2018 13:00:54
If you want to set a hint for text area or input field, then use the HTML placeholder attribute. The hint is the expected value, which gets displayed before the user enters a value, for example, name, details, etc.ExampleYou can try to run the following code to learn how to ... Read More

Is there any Python object inspector?

Rajendra Dharmkar
Published on 24-Jan-2018 12:15:02
There is no single built-in or normal function that acts as a object inspector in Python. There are functions like type(), dir(), vars() or modules like inspect which can be used to find the attributes, properties and methods of any object under inspection.There other functions like id(), getattr(), hasattr(), globals(), ... Read More