Python 3 Tutorials

How to generate random number between 1 and 10 in Python 3

Let’s see how to get a random number between 1 and 10 in python 3 using the random module.

The randint() function of the random module returns the random number between two given numbers. To get a random number between 1 and 10 pass 1 and 10 as the first and second arguments respectively.

Continue Reading >>

How to add pause delay in python using sleep function

In this python 3 tutorial we are going to learn how to pause python script using time.sleep() function.

Often you will need to add a delay to python scripts, which means you pause the execution of the python script for the number of seconds before executing the next line of codes.

We can add delay to python script using time module. The sleep() function of the time module pauses your python program for the specified number of seconds.

Continue Reading >>

How to get Current Date in Python 3

In This Python tutorial we are going to learn how to get current date in python 3 programming. We will also learn how to get current year, month and day separately.

Continue Reading >>

Learn How to Append Items to Python List

In this python 3 tutorial we are going to learn how to append new elements to a python list using python append() function.

In python append() method use to append items to a python list. When you append an item to a list, the new item will be added to the end
of the python list.

Continue Reading >>

Learn How to modify list elements in Python List

In this Python tutorial we are going to learn how to modify the list elements in Python List.

In python 3 we use the index number of the list element to modify individual list elements. Remember that python list starts with the index position 0 not 1. First element of the list has the index position 0, while the second element of the list has the index position 1.

Continue Reading >>

Python Capitalize String using capitalize() and title()

In python capitalize() method capitalizes the first character of the string while the title() method capitalize the first character of the each word of the string.

Python title() Method will return the string with first character of the each word in Uppercase and rest of the characters in lowercase.

Continue Reading >>

Learn How check if a string is a number in Python 3

In this Python 3 tutorial we are going to learn how to check if a string is a number in Python 3 programming.

Python 3 has a built in string function called str.isnumeric() which will check whether a string is a numeric or not. But however str.isnumeric() function will return False for floating point number. To check if a string is a float we can use try except statement.

Continue Reading >>

How to add Python shell to the Atom Text Editor

If you are using the Atom text editor as you python IDE, then you should add the script and Terminal-plus packages to the atom editor. With the script package you can run python programs from the atom text editor and Terminal-plus open the Linux/Unix shell in the atom editor.

To run python scripts in the Atom text editor, we need to Install the script package.

Continue Reading >>

How to Connect to Sqlite Database in Python 3

In this tutorial we are going to learn how to connect to sqlite3 database in python 3 programming.

To connect sqlite database, first we need to import the sqlite3 module. Then, we create the connection to the sqlite database file using sqlite3.connect() function. Finally, once we are done, we should close the connection using sqlite3.close() function.

Python sqlite3 module will look for the database you specify, if the database is not exist python will create a new database.

Continue Reading >>

Learn How to Open Web Browser in Python Script

In this tutorial we are going to learn how open web browser using python 3.

Python has a module called webbrowser, which allows to open the web browser from a python script By simply calling the open() function of the module.

Continue Reading >>

How to Get Current Working Directory in Python 3

In this tutorial we are going to learn how to get current working directory in Python 3 programming language.

In Python 3 we can get the current working directory using os.getcwd() function. getcwd() function is part of the os module, so first of all, we need to import the python 3 os module.

Continue Reading >>

How to Convert integers to strings in Python 3

Often you will need to convert integers to strings in python programming, especially if you want to concatenate integers with strings. In this python 3 tutorial we are going to learn how to convert int to string in python 3.

In python 3 str() function used to convert integers to strings.

Continue Reading >>