Data control language (DCL) is used to access the stored data. It is mainly used for revoke and to grant the user the required access to a database. In the database, this language does not have the feature of rollback.It is a part of the structured query language (SQL).It helps in controlling access to information stored in a database. It complements the data manipulation language (DML) and the data definition language (DDL).It is the simplest among three commands.It provides the administrators, to remove and set database permissions to desired users as needed.These commands are employed to grant, remove and deny ... Read More
To get the index of an item in a single line, use the FindIndex() and Contains() methods.int index = myList.FindIndex(a => a.Contains("Tennis"));Above, we got the index of an element using the FindIndex(), which is assisted by Contains() method for that specific element.Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Program { public static void Main() { List myList = new List () { "Football", "Soccer", "Tennis", }; // finding index ... Read More
At first you have to make a html form like. Validation of a form First name: Last name: Email: Now use jQuery validation plugin to validate forms' data in easier way.first, add jQuery library in your file. then add javascript code: $(document).ready(function() { $("#form").validate(); }); Then to define rules use simple syntax.jQuery(document).ready(function() { jQuery("#forms).validate({ rules: { firstname: 'required', lastname: 'required', u_email: { required: true, ... Read More
Tkinter Entry widgets are used to display a single line text that is generally taken in the form of user Input. We can clear the content of Entry widget by defining a method delete(0, END) which aims to clear all the content in the range. The method can be invoked by defining a function which can be used by creating a Button Object.ExampleIn this example, we have created an entry widget and a button that can be used to clear all the content from the widget.#Import the required libraries from tkinter import * #Create an instance of tkinter frame ... Read More
To extract CSV file for specific columns to list in python, we can use Pandas read_csv() method.StepsMake a list of columns that have to be extracted.Use read_csv() method to extract the CSV file data into a data frame.Print the exracted data.Plot the data frame using plot() method.To display the figure, use show() method.Exampleimport pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True columns = ["Name", "Marks"] df = pd.read_csv("input.csv", usecols=columns) print("Contents in csv file:", df) plt.plot(df.Name, df.Marks) plt.show()OutputRead More
The following code shows how to get return value from a function in a Python class.Exampleclass Score(): def __init__(self): self.score = 0 self.num_enemies = 5 self.num_lives = 3 def setScore(self, num): self.score = num def getScore(self): return self.score def getEnemies(self): return self.num_enemies def getLives(self): return self.num_lives s = Score() s.setScore(9) print s.getScore() print s.getEnemies() print s.getLives()Output9 5 3
To upload a file, the HTML form must have the enctype attribute set to multipart/form-data. The input tag with the file type creates a "Browse" button.Example File: OutputThe result of this code is the following form −File: Choose file UploadHere is the script save_file.py to handle file upload −#!/usr/bin/python import cgi, os import cgitb; cgitb.enable() form = cgi.FieldStorage() # Get filename here. fileitem = form['filename'] # Test if the file was uploaded if fileitem.filename: # strip leading path from file name to avoid # directory traversal attacks ... Read More
Suppose there is an HTML file as below − FirstName: LastName: After submitting this form it should go to a Python page named "getData.py", where you should fetch the data from this HTML page and show. then below is the code for Python CGI. #!C:\Python27\python.exe # Import modules for CGI handling import cgi, cgitb # Create instance of FieldStorage form = cgi.FieldStorage() # Get data from fields first_name = form.getvalue('first_name') last_name = form.getvalue('last_name') print("Content-type:text/html") print print("") print("") print("Hello - Second CGI Program") print("") print("") print(" ... Read More
While creating a function the single asterisk (*) defined to accept and allow users to pass any number of positional arguments. And in the same way the double asterisk (**) defined to accept any number of keyword arguments. The single asterisk (*) can be used when we are not sure how many arguments are going to be passed to a function and those arguments that are not keywords. The double asterisk (**kwargs) can be used to pass keywords, when we don't know how many keyword arguments will be passed to a function, which will be in a dict named ... Read More
The double star/asterisk (*) operator has more than one meaning in Python. We can use it as a exponential operator, used as function *kwargs, unpacking the iterables, and used to Merge the Dictionaries. Exponential operator For numeric data the double asterisk (**) is used as an exponential operator. Let's take an example and see how the double star operator works on numeric operands. Example The following example uses double asterisks/star (**) to calculate “a to the power b” and it works equivalent to the pow() function. a = 10 b = 2 result = a ** b print("a**b = ", ... Read More