Quotation in Python

Mohd Mohtashim
Updated on 24-Jan-2020 11:20:02

5K+ Views

Python accepts single ('), double (") and triple (''' or """) quotes to denote string literals, as long as the same type of quote starts and ends the string.The triple quotes are used to span the string across multiple lines. For example, all the following are legal −word = 'word' sentence = "This is a sentence." paragraph = """This is a paragraph. It is made up of multiple lines and sentences."""

Lines and Indentation in Python

Mohd Mohtashim
Updated on 24-Jan-2020 11:18:54

2K+ Views

Python provides no braces to indicate blocks of code for class and function definitions or flow control. Blocks of code are denoted by line indentation, which is rigidly enforced.The number of spaces in the indentation is variable, but all statements within the block must be indented the same amount. For example −if True: print "True" else: print "False"However, the following block generates an error −if True: print "Answer" print "True" else: print "Answer" print "False"Thus, in Python all the continuous lines indented with same number of spaces would form a block. The following example has various statement blocks −Note − ... Read More

HTML File Input Control Capture and Accept Attributes Issue

Lakshmi Srinivas
Updated on 24-Jan-2020 11:18:21

607 Views

Use the accept attribute to set the types of files that the server accepts in HTML. Use the attribute only with .ExampleYou can try to run the following code to work with the accept attribute:              File Upload Box                                             The capture attribute is a boolean attribute that, if specified, indicates that the capture of media directly from the device...is preferred.The capture attribute is NOT used to include the camera option in the dialog but to indicate that direct capture from the webcam is preferred.  The "correct" code is given below

What Are Python Identifiers

Mohd Mohtashim
Updated on 24-Jan-2020 11:10:50

6K+ Views

A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).Python does not allow punctuation characters such as @, $, and % within identifiers. Python is a case sensitive programming language. Thus, Manpower and manpower are two different identifiers in Python.Here are naming conventions for Python identifiers −Class names start with an uppercase letter. All other identifiers start with a lowercase letter.Starting an identifier with ... Read More

Python Environment Variables

Mohd Mohtashim
Updated on 24-Jan-2020 11:07:59

990 Views

Here are important environment variables, which can be recognized by Python −Sr.No.Variable & Description1PYTHONPATHIt has a role similar to PATH. This variable tells the Python interpreter where to locate the module files imported into a program. It should include the Python source library directory and the directories containing Python source code. PYTHONPATH is sometimes preset by the Python installer.2PYTHONSTARTUPIt contains the path of an initialization file containing Python source code. It is executed every time you start the interpreter. It is named as .pythonrc.py in Unix and it contains commands that load utilities or modify PYTHONPATH.3PYTHONCASEOKIt is used in Windows ... Read More

Installing Python on Mac OS

Mohd Mohtashim
Updated on 24-Jan-2020 11:06:37

587 Views

Python distribution is available for a wide variety of platforms. You need to download only the binary code applicable for your platform and install Python.If the binary code for your platform is not available, you need a C compiler to compile the source code manually. Compiling the source code offers more flexibility in terms of choice of features that you require in your installation.Recent Macs come with Python installed, but it may be several years out of date. Seehttp://www.python.org/download/mac/ for instructions on getting the current version along with extra tools to support development on the Mac. For older Mac OS's ... Read More

Installing Python on Linux

Mohd Mohtashim
Updated on 24-Jan-2020 11:01:47

618 Views

Python distribution is available for a wide variety of platforms. You need to download only the binary code applicable for your platform and install Python.If the binary code for your platform is not available, you need a C compiler to compile the source code manually. Compiling the source code offers more flexibility in terms of choice of features that you require in your installation.Here are the simple steps to install Python on Unix/Linux machine.Open a Web browser and go to https://www.python.org/downloads/Follow the link to download zipped source code available for Unix/Linux.Download and extract files.Editing the Modules/Setup file if you want to customize ... Read More

Why You Should Learn Python Programming

Mohd Mohtashim
Updated on 24-Jan-2020 10:58:56

301 Views

Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. It uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages.Python is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Web Development Domain. I will list down some of the key advantages of learning Python −Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. This is similar to PERL ... Read More

Zoom HTML5 Canvas to Mouse Cursor

Ankith Reddy
Updated on 24-Jan-2020 10:52:18

1K+ Views

The canvas always scales from its current origin. The default origin is [0, 0]. If you want to scale from another point, you can first do ctx.translate(desiredX, desiredY);. This will reset the origin of the canvas to [desiredX, desiredY].The translate() method remaps the (0, 0) position on the canvas. The scale() method scales the current drawing, bigger or smaller. If you want to translate() the canvas context by your offset, you need to first scale() it to zoom in or out, and then translate() back by the opposite of the mouse offset.These steps are given in the following examplectx.translate(pt.x, pt.y); ... Read More

Use JSF with HTML 4.5 and Facelets

George John
Updated on 24-Jan-2020 10:47:16

179 Views

Facelets is an open-source Web template system for JavaServer Faces (JSF). The language requires valid input XML documents to work. Facelets supports all of the JSF UI components and focuses completely on building the JSF component tree, reflecting the view for a JSF application.Facelets is a XML based view technology. It cannot be used with HTML4 doctype. You can use with JSF/Facelets, even without a declaration in top of the page.           Title               Header       Nav       Main       Footer    

Advertisements