Pawandeep Kaur has Published 35 Answers

Explain Python vs Scala

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:39:39

Python and Scala are both programming languages. Python is a high level programming language which is used in many sectors including development, machine learning, artificial intelligence and data analytics. Scala is the programming language which runs on JVM(Java Virtual Machine).It is used for functional programming and strong static systems. Scala ... Read More

How to read a text file in Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:39:07

A text file is the file containing simple text. Python provides inbuilt functions to read, create and write text files. We will discuss how to read a text file in Python.There are three ways to read a text file in Python −read() − This method reads the entire file and ... Read More

How to plot a graph in Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:37:28

Graphs in Python can be plotted by using the Matplotlib library. Matplotlib library is mainly used for graph plotting.You need to install matplotlib before using it to plot graphs. Matplotlib is used to draw a simple line, bargraphs, histograms and piecharts. Inbuilt functions are available to draw all types of ... Read More

Explain and show the use of UNION in MySQL using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:37:11

The UNION statement is used to combine the results of the two SELECT queries without repeating the duplicate values. If both the SELECT queries return same row, it is listed only once.To perform the UNION on two select statements, The number of columns returned must be sameThe datatypes of the ... Read More

Explain the use of AVG() function in MySQL using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:32:37

The AVG() function is one of the arithmetic functions in MySQL.As the name suggests the AVG() function is used to return the average of a numerical column in the table.SyntaxSELECT AVG(column_name) FROM table_nameSteps you need to follow to use AVG() function on a table using MySQL in pythonimport MySQLl connectorestablish ... Read More

How to perform arithmetic across columns of a MySQL table using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:32:14

The arithmetic operations as the name suggests are used to perform the operations such as additon, subtraction, division, multiplication or modulus.The arithmetic operations are operated on the numeric data in your table.SyntaxTo perform additionSELECT op1+op2 FROM table_nameHere, the op1 and op2 are the column names or the numeric values. If ... Read More

How to add a column to a MySQL table in Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:31:53

It may be sometimes required to add a new column in a existing table. Suppose we have a “Students” table with columns such as Name, Age, Roll no. We want to add a new column “Address” into our existing table.This can be done by using the ALTER command. The ALTER ... Read More

How can you test if some record exists or not in a MySQL table using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:31:34

We may at times need to check if a particular record exists in a table or not.This can de done using the EXISTS statement. The EXISTS statement returns true if the following subquery returns one or more records.SyntaxSELECT * FROM table_name WHERE EXISTS(sub_query)The subquery if returns one or more rows, ... Read More

How to show all the tables present in the database and server in MySQL using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:31:12

We may sometimes require to get the list of all the tables present in our database. This can be done by using the SHOW TABLES command.The SHOW TABLES command is used to display the table names in a database as well as the server.SyntaxTo show the tables present in a ... Read More

How to count SQL table columns using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:30:12

It may be required to count the number of columns present in a SQL table.This is done using count(*) function with information_schema.columns and the WHERE clause. The WHERE clause is used to specify the name of the table whose columns are to be counted.SyntaxSELECT COUNT(*) FROM information_schema.columns WHERE table_name= ‘your_table_name’Steps ... Read More

Advertisements