Posts

Showing posts with the label Python Programming

How To Use While Loops In Python

Image
How To Use While Loops In Python Overview  This beginners Python guide will explain the steps for working with 'while' loops in Python for beginners. Introduction  The Python while loops help to execute a set of statements in Python functions,  as long as a particular specified condition is True. Let us understand the while loop with a simple python example exercise, of a while loop usage, where we are trying to count numbers from 1 to 10, with a condition of the number being less than 10. We create a variable called num, and initiate it with a initial value of 1 and we carry out iteration of this num variable, whereby, it is incrementing every time it loops, by incrementing by 1.  Code num = 1 while num < 10 :       print(num)       num += 1 # output   1 2 3 4 5 6 7   8  9 In the above case, we performed iteration of the while loop where every time the loop iterates, the num variable gets incremented by 1 a...

Essentials About Python Return Statement

Image
Essentials About Python Return Statement                                                                          photo credit:Rubaitul Azad,  Unsplash  Introduction This post will guide you step-by-step on Python return statement with indepth details and examples to give you a very clear picture on the concept of return statement in Python as well as the usage of the return statement. Using return statements needs a good understanding of the definition of the return statement that we will be learning soon in the following passages. Also, we will see as we start doing python projects, that, the skill in using the return statement, that is, when to use the return statement, how to use the return statement.     What Is A Return Statement The keyword return is a Python in-built keywo...

Python Input() Mastery: Getting Your Python Code to Listen

Image
 Python Input() Mastery: Getting Your Python Code to Listen  Introduction  This Python Beginner tutorial will guide you on the usage of input() function in python. We use input function in all our Python Projects, so, it's necessary to understand,  what is input function, how it is used and why it is used in python projects.  What is input() function  Python input() function is a function that accepts input values from a user when prompted to provide an input. It is an inbuilt function that reads the input values from the user and after evaluating it, by default, the input() function will return the input as a string. The input function doesn't have parameters inside its parenthesis, but, it takes a prompt in the form of a string inside it's parenthesis. For example: Consider a variable that you created , name, and you want to get input of different name values from the user, so you use the input function with a prompt inside it's parenthesis as shown below...

Stop Mixing Them Up: Arguments vs Parameters in Python

Image
Stop Mixing Them Up: Arguments vs Parameters in Python      INTRODUCTION \ As a beginner learning Python, we are always coming across the terms parameters and arguments frequently and many new coders are often confused with the two different terms parameters and arguments, with the consequence that they even use it wrongly many times. This post is to sort out the differences between the two terms, parameters and arguments accordingly to their usage in Python functions. WHAT ARE PARAMETERS A parameter in Python is actually a variable created in that function, that works like a placeholder for some data value that the function will be use later.  For example, if we consider an example a function add_num which is used to add two numbers, then it will be written the following manner:  def add_num(x,y): In this above situation, add_num is the name of the function with a task of adding the two number variables x and y. def or define is used to define or descraibe the ...

A Deep Dive Into Mastering 'def' in Python

Image
  A Deep Dive Into Mastering 'def' in Python This Post has migrated to my Substack Newsletter,Please read the Updated Post here . INTRODUCTION For all those code newbies who find it hard to digest the usage and where withals of  the term def that appears a lot of time while coding in Python, here is a great news! I am going to explain not only what is the def that is used so frequently in all of the Python projects, but also, it's usage, why it is used and how it is used in detailed steps. WHAT IS def The def keyword is used for describing or defining a Python function in which we need to implement certain specified tasks. We require various tasks to be done inside a function, such as calculating the sume of numbers, carrying out subtraction of numbers, finding the average of numbers, finding Grades based on score , etc. I will be outlining below, the various tasks that could be performed inside the def function and I will be also guiding you on each of them step-by-step ci...

BUILD A TODO LIST IN PYTHON

Image
Build a TODO List in Python|Python For Beginners  Overview The objective is to build a todo list to which we can add items, remove the added items, edit the items and even if required, delete out the entire list itself. We will learn here step by step, how to build the todo list with the above  CRUD (Create, Remove, Update/edit, and Delete ) features.  This is a CRUD list  app  that we are building as we can Create, Remove, Update items in the list and Delete the entire list itself. We will be using Python3 to build this Project. Introduction This Python project explanation is for beginners learning Python Programming. By doing this simple Todo list, you will learn several concepts of Python, such as while True loops, if-elif-else loops, for loop, adding, updating, removing items from a list , def() function, etc.  Importing os and time We import time to let the screen pause for a while before clearing  and we import os to clear the screen . Initializi...