Reversing an integer number is an easy task. We may encounter certain scenarios where it will be required to reverse a number.Input: 12345 Output: 54321There are two ways, we can reverse a number −Convert the number into a string, reverse the string and reconvert it into an integerReverse mathematically without converting into a stringConvert into string and ReverseThis method of reversing a number is easy and doesn’t require any logic. We will simply convert the number into string and reverse it and then reconvert the reversed string into integer. We can use any suitable method for reversing the string.Example Live Demodef ... Read More
A Dictionary in Python is a type of data structure.It consists of a collection of key-value pairs. Each key in the dictionary is unique. Each unique key in the dictionary is associated to its value. Thus, Dictionary holds key : value pairs.We will be discussing how to create a dictionary in Python.Create a DictionaryA dictionary in Python can be created by placing various key: value pairs inside curly braces .The key:value pairs are separated from each other using commas(, ). The values in the dictionary can be of any datatype and can be duplicated. However, the keys in the dictionary ... Read More
Type conversion is at times needed when the user wants to convert one data type into another data type according to requirement.Python has in-built function str() to convert an integer to a string. We will be discussing various other methods in addition to this to convert int into string in Python.Using str()This is the most commonly used method to convert int into string in Python.The str() takes integer variable as a parameter and converts it into a string.Syntaxstr(integer variable)Example Live Demonum=2 print("Datatype before conversion", type(num)) num=str(num) print(num) print("Datatype after conversion", type(num))OutputDatatype before conversion 2 Datatype after conversion The type() function ... Read More
There may be some situations, where we need to convert a list into a string. We will discuss different methods to do the same.IterationIterate through the list and append the elements to the string to convert list into a string. We will use for-in loop to iterate through the list elements.Example Live Demolist1=["Welcome", "To", "Tutorials", "Point"] string1="" for i in list1: string1=string1+i string2="" for i in list1: string2=string2+i+" " print(string1) print(string2)OutputWelcomeToTutorialsPoint Welcome To Tutorials PointUsing .join() methodThe list will be passed as a parameter inside the join method.Example Live Demolist1=["Welcome", "To", "Tutorials", "Point"] string1="" print(string1.join(list1)) string2=" " print(string2.join(list1))OutputWelcomeToTutorialsPoint Welcome To ... Read More
After writing the code, we need to run the code to execute and obtain the output. On running the program, we can check whether the code is written is correct and produces the desired output.Running a python program is quite an easy task.Run on IDLETo run a python program on IDLE, follow the given steps −Write the python code and save it.To run the program, go to Run > Run Module or simply click F5.Run on Command LineThe python script file is saved with ‘.py’ extension. After saving the python script, we can run it from the Command Line. In ... Read More
Python has no in-built function to reverse a string. Thus, we need to implement our own logic to reverse a string.We will reverse a string using different methods.Using FOR LoopThe idea behind this method is to use a reverse loop starting from the last index of the string to the 0th index. At each iteration, we will be adding characters of the string to hold the reversed string at the end of the iterations.Let’s look on the general procedure we will be following −a:=new stringloop from last index of string to 0th index and decrement by 1 a=a+character at the ... Read More
MySQL uses port number 3306 by default.3306 Port Number3306 port number is used by MySQL protocol to connect with the MySQL clients and utilities such as ‘mysqldump’. It is a TCP, i.e Transmission Control Protocol.VulnerabilitiesLet us see if there are any vulnerabilities while using this default port −In general, port 3306 shouldn’t be opened since it could make the server vulnerable to attack. If the user needs to connect to the database remotely, there are many other secure options, instead of opening the port 3306.One of the secure options includes using an SSH tunnel. On the other hand, if it ... Read More
To determine the connection method that is used by MySQL connection, the below command can be used −netstat −ln | grep 'mysql'On Unix, MySQL programs treat the host name ‘localhost’ in a special manner. Hence, it behaves differently than what is expected of it.Type of ConnectionTo know the type of connection from within the mysql CLI, the below command can be used −mysql> \sOutput −Connection: 127.0.0.1 via TCP/IP (or) Connection: Localhost via UNIX socketTCP/IP connection to the local serverTo ensure that the client makes a TCP/IP connection to the local server, the --host or -h can be used. This will ... Read More
Let us look at the administrative and utility programs in MySQL and understand how they can be used −ibd2sdiIt is a utility to extract serialized dictionary information (SDI) from InnoDB tablespace files. SDI data is present all persistent InnoDB tablespace files. ibd2sdi can be used at runtime or when the server is offline.innochecksumIt prints the checksums for InnoDB files. It reads an InnoDB tablespace file, calculates the checksum for every page, compares the calculated checksum to the stored checksum, and reports mismatches, which show the damaged pages. It was originally developed to speed up the verification of the integrity of ... Read More
The mysqlslap utility is a diagnostic program that has designed to emulate client load for a MySQL server and report the timing of every stage. It works as though multiple clients are accessing the server.Invoking mysqlslapmysqlslap can be invoked using the below command −shell> mysqlslap [options]Some options are: --create or --query that would enable the user to specify a string that contains an SQL statement or a file containing statements.Stagesmysqlslap runs in three stages. They are −Create schema, table, and any stored programs or data to use (it is optional) for the test. This stage uses a single client connection.Run ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP