Browsed by
Tag: python programming

Return statement in Python Function

Return statement in Python Function

In this session, we will be discussing Return statement in Python Function. In our previous two sessions, we understood basics of functions and parameterized functions. Today we will see how we can make a function to evaluate some instruction and return the result back to the function call. To make function return some result, we make use of Python Keyword ‘return’. There are 2 ways to use ‘return’ keyword in a function – using without expression/result and using with expression/result….

Read More Read More

Functions in Python – Introduction

Functions in Python – Introduction

In this session we will be working with functions in Python. Function is a piece of code that performs a specific task and we can re-use that function any number of times in our code. If we feel that the functionality that we are coding is too long, then its better to decompose the code into multiple parts/smaller functionalities and create functions are around them. For example, if we are building code to create calculator, then as a developer we…

Read More Read More

Python List Comprehension

Python List Comprehension

Hi Friends, welcome to yet another interesting session on Python List Comprehension. Today we will see another way to fill a list with its elements. In previous sessions, we have seen that we can add elements in a list using ‘append’ and ‘insert’ method. However, these methods may not be the best option when you want to add large number of elements in the list since we have add elements one by one. In such cases, there is another way…

Read More Read More

Methods in Python Lists

Methods in Python Lists

Hi Friends……Welcome again to our session on Methods in Python Lists. In the previous session, we had a detailed understanding about Python Lists. We will extend this session now to see how we can make use of the lists and some pre-defined methods and functions to be used with Python Lists. Lets start our session on Methods in Python Lists: 1. sort method on integers – Python Lists provides us with an in-build method to sort the list. Instead of…

Read More Read More

Python Lists

Python Lists

In this session, we will discuss about Python Lists – Uses and Features. So far, we have seen the use of variables which can hold only single value. Like var = 1 or str = ”Python”. These variables cannot hold more than 1 value at  a time. Either we can change their current value, or we must declare more variables. Now imagine a situation where you are writing a program where you would need 100 or 1000 variables. In such…

Read More Read More

Difference between logical and bitwise operator

Difference between logical and bitwise operator

Hi Friends, welcome to yet another session in our Python Tutorial Series. Today we will see the Difference between logical and bitwise operator in Python. We have already seen mathematical operators in Python in another session: Lets see below logical and bitwise operators one by one: Logical Operator: Logical operators return the logical output of the expression on which the operator is applied. The answer can be either True/False or 1/0. Below are the logical operators: and operator – This…

Read More Read More

break and continue statement in Python

break and continue statement in Python

In this session, we will see the use and functionality of break and continue statement in Python. ‘break’ and ‘continue’ are the statement that are used to change the course of ‘for’ and ‘while’ loops. In other words, you can control the execution of these loops using break and continue. They are the Python reserved keywords and you cannot use them for naming user defined variables or functions. break – There might be some situation where you want to exit…

Read More Read More

for loop in Python

for loop in Python

Hi Friends…lets continue our Python Tutorials journey with ‘for loop in Python’. Python for loop is used is when we want to iterate over an activity more than one time.Although while loop also does the same thing but we use for loop, when we know the number of times we want our loop to execute. In while loop, we are not sure how many times we want to execute; the loop continues till the condition is True. Also, in for…

Read More Read More

Python while loop

Python while loop

In this Python Tutorial, we will see the use of Python while loop. But before that lets ask what exactly is loop and why do we need it. Loop is something which performs some activity as long as you want it to be done. For example, if we want to play tennis if it’s not raining outside, then we may write something like this: while its_not_raining_outside: lets_play_tennis() Indentation rules work here just like if-else statement we saw in previous session….

Read More Read More

if-else statement in Python

if-else statement in Python

In this tutorial, we will see the use of if-else statement in Python. It is useful when we want to take decision based on some condition. For example, if I am hungry, I will go for lunch. Here I am deciding that I will go for lunch when I am hungry. To code such things, we need if-else statement. Before directly going for Python if-else statement, let’s just revise the Python Operator priorities table and put some more operators: Priority…

Read More Read More