wondering how to split a string in python? Python has in-built function split that splits a string. Split Function By default python split function splits string by space and returns list of splitted string. Example str=”Once upon a time” print(str.split(” “)) Output: [“Once”,”upon”,”a”,”time”] Similarly we can pass any separator we want. Example str=”once-upon-a-time” print(str.split(“-“)) Output: […]
How to reverse a string in python?
In certain situation, you may want to reverse the string using Python programming language. Following is the right way to do it. Reverse a string in python In python, there is no in built function available which can reverse a string. However we can use slice in backwards to print the string in the reverse. […]
How to write a comment in python ?
Often we are required to write comments inside a python script. Unlike C,C++,Java,.Net in python, writing a comment is bit different. How to write a comment in Python? In python, we can write single line comment and multiline comment. Single line comment Begins with # Example #this is an example of single line comment Multiline […]
PHP: Remove Space at the end of string
There is a string that ends with a single white space. You can use PHP trim function to remove the white space at the end of the string. PHP trim() Function This function not only removes white space at the end of the string but also at the beginning of the string. <?php echo $username; […]
PHP: Remove Extra Spaces around a string
In many times, you may see there are strings with extra spaces around it and you may want to remove those extra spaces. By using PHP function trim function, you can remove those extra spaces around the string. Example <?php echo $username; ?> Output: ” srikant […]
PHP Error Types
While coding, or developing a PHP website or even in production stage, a website encounters. These errors could be result of wrong coding, mistake in the code, wrong implementation of code or any similar reason. PHP has list of errors that occur in a web project. PHP Error Types Parse Error Parse Error also known […]
PHP Constants
Constants are used in a PHP project whose value never changes. Such values can be defined as constant variables. The only important point we need to remember, PHP Constant variable values can not be overwritten.Such variables are defined once and remains same as long as website exists. PHP Constant PHP constant can be defined using […]
PHP Super Global Variables
PHP has provided predefined variables which are called super globarl variables. In a PHP website project, there might be situation to store logged in user information, access web url info and server related data. In such cases, super global variables are useful. PHP Super Global Variables There are nine types of Super Global Variables exist […]
PHPMyAdmin Installation for Nginx Server in Ubuntu 20.04 Cloud Hosting
For easy access to MySQL server, we need phpmyadmin. Following article guides how to install phpmyadmin for Nginx Server in Ubuntu 20.04. If you have not installed mysql server yet, then follow chapter 7 of this tutorial series. All the chapter list are present below this article. PHPMyAdmin Installation for Nginx Login to your Ubuntu […]
Install PHP for Nginx Server in Ubuntu 20.04 Operating System Cloud Hosting
Unlike Apache Server, Nginx server has no native PHP installed. So we are required to install PHP-FPM. The full form of FPM is FastCGI Process Manager. Following article, will help you to install php and php mysql as well. PHP Installation in Nginx Server Following command will update all the required updates and also going […]
Set Firewall for Nginx Server in Ubuntu 20.04 Cloud Hosting
Firewall is essential to restrict allow of required Network traffic and disallow other network traffic. While setting up Ubuntu Operating system, we define firewall for openssh. (If you have no idea about this, check chapter 3 of this cloud hosting tutorial series. All the chapter list are present below this article.) After successfull installation of […]
Install Nginx Server in Digital Ocean, AWS, Google Cloud Hosting Ubunt 20.04
Nginx server has been gaining name in the world of server preference. Following guide is helfpul to install Nginx server in Ubuntu 20.04 Operating system hosted at Cloud Hosting(Digital Ocean, Amazon AWS or Google) Nginx Server Installation To install Nginx server, you must have to login into Ubuntu OS using Putty with non-root user and […]
Install Free Powerful SSL Certificate for Apache Server in Ubuntu 20.04 Lets Encrypt
One of the important SEO factor is website is hosted upon https rather than http. It is only possible after installing a valid SSL certificate. SSL certificate are bit expensive and bit complex also to install. And website owners who have just started their web application find bit tough to pay this extra cost. Luckily […]
Add Sub Domain in Digital Ocean Cloud Hosting Droplet Ubuntu 20.04
Sub domain are useful to create multiple sub-websites for a website. Digital Ocean Cloud Hosting Droplet can be used to host multiple sub domain. In this article we are going to learn how to add a sub domain. Prerequisite: Login using putty with non root user with super user privilege Add Domain Name to Digital […]
Add Multiple Domain Name To Digital Ocean Cloud Hosting Ubuntu 20.04
In previous chapter, I had discussed about adding a single domain name to digital ocean cloud hosting (Ubuntu 20.04). If you have followed that chapter, then adding multiple domain name is just a piece of cake. Adding Multiple Domain Name In previous chapter I had discussed how to add a domain name to a droplet. […]
Add Domain Name to Digital Ocean Cloud Hosting
In this article we are going to learn how to set a purchased domain name in Digital Ocean Cloud Hosting. To host a website in digital ocean cloud hosting, we have to create a droplet first. Droplet Droplet is a reference name, digital ocean has been using to refer to mini-server inside their master server. […]
PHPMyAdmin Installation and Security for Apache Server Ubuntu 20.04
PHPMyAdmin is a cool interface that helps to manage MySQL Databases easily. Following step by step article is going to help you to understand installation of PHPMyAdmin for Apache Server Ubuntu 20.04. Installation is not sufficient we have to implement security features as well. Login to your Ubuntu 20.04 hosted at cloud hosting with your […]
Install PHP in Apache Server Ubuntu 20.04
PHP installation in Apache server is easy. If you are Ubuntu 20.04 operating system in your cloud hosting, then following step by step guide is going to help you to install PHP. PHP Installation Installing PHP only is not sufficient to run a web application which has PHP as server side scripting. We need libapache2 […]
Install MySQL in Ubuntu 20.04 Apache Server
MySQL server is essential to maintain a database for web application. MySQL is best suitable for relational database management system projects. Following article is going to guide you to insall MySQL in Apache server(Ubuntu 20.04 version) MySQL Installation First of all, login with your non root username and password with super user privileges.(If you have […]
Install Apache Server in Ubuntu 20.04 Operating System Cloud Hosting
In cloud hosting, once ubuntu server 20.04 is installed successfully, then to upload a web application (website) we need a server software package. Currently Apache and Nginx are two popular server software packages. If you are confused which one to use, I would recommend to install Apache because there are flood of tutorials available for […]
Create Swap Sace to Protect MySQL Database from crashing Ubuntu 20.04 Server
Applications installed in a ubuntu server is dependent upon RAM and other resources. If for some reason entire RAM memory is consumed then chances are it may impact on other applications and mysql database may crash. Recently I had encountered with my new web application installed in Cloud hosting. Hacker with the help of bot […]
Set timezone and Time Synchronization in Ubuntu 20.04 Server
We often ignore this vital part time synchronization while setting up Ubuntu 20.04 server. By default the time zone of installed ubuntu 20.04 server is set to the cloud hosting server provider’s system time. And if you are installing your web application in the server, then you might want your web application time reference should […]
Setup Firewall in Ubuntu 20.04 Server
Firewall is important in any server setup. It helps to allow required network traffic and restricts rest. Most importantly if firewall is not set correctly then it would open doors for the hackers. Following tutorial on setting up firewall in Ubuntu 20.04 Server is helpful to set it right. Login with your user name and […]
Create super user in Ubuntu 20.04 Server By using PUTTY Software application
Once Ubuntu operating system is loaded into the rented cloud hosting, the first job would be to create a user. This new user should have super user privileges. Current version of Ubuntu : 20.04 By default the super user of ubuntu server is Root and you must have received a system generated password from the […]
Introduction to Web Hosting
Web Hosting is essential for every web application. And if you are confused to decide which hosting is suitable for your project? Then, this step by step complete article is going to put light on web hosting in detail. At the end of this article you will be completely aware about the right hosting option […]
PHP MySQLi Delete Record
So far, I have discussed about connection establishment, create table, insert record, read records (select statement), update record. In this article we are going to learn about delete a record. Following is the table which I am going to delete a record. This table name is emp_info emp_id emp_name emp_age 1 Raj 22 2 Rahul […]
PHP MySQLi Update Records
In some cases, we may want to update table data using update sql statement. Lets see how can we update. The table which I am using to update record is as below. The table name is emp_info emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 […]
PHP MySQLi Read Records (Select Statement)
So far we have learned how to establish connection with mysql database using mysqli, create table, insert record. In this tutorial, we are going to learn how to print records from the table. For this we are going to use sql select statement. The table from which I am going to fetch record is as […]
PHP MySQLi Insert Record
In previous tutorial, we have learned how to create a table using mysqli and php. In this article we are going to learn how to insert record into table. For reference look at the below table. emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 In […]
PHP MySQLi Create Table
The first job, in php database project can be creating a table. In this article, we will learn how to create a table in mysql database using php and mysqli. (See following table example) emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 Lets see how […]
PHP MySQLi Establish Connection
In this first article of PHP MySQLi Tutorial, we are going to learn how to establish database connection with mysql database. Before proceeding further, you must have following knowledge Basics of PHP MySQL commands (create table, insert row, select row, update row, delete row etc.) What is MySQLi? MySQLi is a php based library which […]
Python PyMySQL delete record
So far, I have discussed about connection establishment, create table, insert record, read records (select statement), update record. In this article we are going to learn about delete a record. Following is the table which I am going to delete a record. the table name is emp_info emp_id emp_name emp_age 1 Raj 22 2 Rahul […]
Python PyMySQL Update Record
In some cases, we may want to update table data using update sql statement. Lets see how can we update. The table which I am using to update record is as below. emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 In the above table, lets […]
Python PyMySQL Read Records (Select Statement)
So far we have learned how to establish connection with mysql database using pymysql, create table, insert record. In this tutorial, we are going to learn how to print records from the table. For this we are going to use sql select statement. The table from which I am going to fetch record is as […]
Python PyMySQL Insert Record
In previous tutorial, we have learned how to create a table using pymysql and python. In this article we are going to learn how to insert record into table. For reference look at the below table. emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 In […]
Python PyMySQL Create Table
The first job, in python database project can be creating a table. In this article, we will learn how to create a table in mysql database using python and pymysql. (See following table example) emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 Lets see how […]
Python PyMySQL Establish Connection
In this first article of Python PyMySQL Tutorial, we are going to learn how to establish database connection with mysql database. Before proceeding further, you must have following knowledge Basics of Python MySQL commands (create table, insert row, select row, update row, delete row etc.) To establish connection with a database like MYSQL server, we […]
Python Count the number of occurrence of a sub string in a string?
Lets see how to find out the number of occurrence of a sub string in a string. Example: sentence=”This is a lovely day and this day could be your best day, if you smile” Count how many times the word ‘day’ (substring) is appearing in the above sentence (string) Solution 1 sentence=”This is a lovely […]
Python how to check if list contains element?
In python, we can check if a list contains certain element. For this “in” keyword is helpful. Example selected_candidates=[“rahul”,”ajay”,”vijay”] #check if raju is present in the list if “raju” in selected_candidates: print(“Raju has been selected for the job”) else: print(“Raju has been disqualified for the job”) Output: Raju has been disqualified for the job.
Read html file in python beautifulsoup
Beautifulsoup is a powerful library that helps scrape complex to complex html website easily. Python+Requests+Beautifulsoup=Successful Web Scraping Read html file in python beautifulsoup To use beautifulsoup library, this library must be present in the system. If you are using pycharm, then go to file then project settings and install bs4. bs4 contains beautifulsoup library. Following […]
Python How to make a dictionary from two lists?
We have two lists. And we want to create a dictionary combining values of these two lists. In such case, we can create a dictionary from two lists as following way. Example name_list=[“rahul”,”vijay”,”ajay”] phone_list=[“1111″,”2222″,”3333”] #declare an empty dictionary phone_book={} for idnum in range(0,len(name_list)): phone_book.add(name_list[idnum],phone_list[idnum]) #lets print the dictionary print(phone_book) Output: { “rahul”:”1111″, “vijay”:”2222″ “ajay”:”3333″ } […]
Python how to check if string contains substring?
In certain situation, you may want to know whether a sting contains another sub-string. Then the helpful tool that eases the process of knowing this is, “in” keyword. It checks whether the supplied element is present in the target element or not. If element is present then it would return true otherwise it would return […]
How to make python print something multiple times?
Python has print function which prints the passed argument. And in some cases we may want to print a message multiple times. If we want to print something multiple times then for loop is an easy option. for _ in range(0,10): print(“hello friend”) Output: hello friend hello friend hello friend hello friend hello friend hello […]
Check if a python dictionary contains a key
Dictionary are the one of the very powerful data listing option available in python. Unlike list and tuple, dictionary hold data in key and value pair. So in some cases the developer may want to find out if a certain key is present. Lets see how to check if a python dictionary contains a key? […]
Check if a python string contains a character
In some cases we may want to check if string contains a certain character. To do check presence of a character in a string in python, we can use the in keyword functionality. If element is present then it would return true other wise it would return false. Example sentence=”Orange is not apple” #lets check […]
How to go through every character in a string python?
Python treats a string as sequence of characters. Which means in the eyes of python, a string list of characters. Therefore to access a character in a string we must have to call it by its index number. Every Character in a String With the help of for loop we can print every character of […]
Connect MS Access database in python (pyodbc)
MS access is also used as database to store and update data. In python projects we can use ms access as database and for that pyodbc library is required. Install pyodbc library Assuming you have prior known of python and library installation, run the following command in your terminal or command prompt. pip install pyodbc […]
How to select li element in selenium python?
In certain cases we may want to fetch data from list by using Selenium in Python. The simplest solution to target any element by its tag name is to use find_element_by_tag_name. Note: Selenium Python has similar function find_elements_by_tag_name. Do not use this one. It returns a list of targeted element. Select li element in selenium […]
How to launch Internet Explorer IE browser in selenium python?
Assuming you have prior knowledge of Python and Selenium, following are the step by step guideline to launch Internet Explorer browser in Selenium Python. To run internet explorer browser from selenium python, you must have to have internet explorer driver available in your system. You can download it from selenium’s official website. Selenium Official Website: […]
How to add new python interpreter in pycharm?
In mac OS and Linux OS, python older version is pre-installed. So if we run pycharm, then by default pycharm picks older version of python which is 2.7. But we want the latest version 3.0 as interpreter in pycharm. So following is the solution to add new python interpreter in pycharm. Open pycharm and launch […]