You are here: Home / Topics / Search / Python
Showing 22 Search Results for : Python

While loop in python

By Yogesh on 31 Aug 22 | Filed under: Python
In python , there are two type of loops-- for loop- while loopwhile loop are simple loop which run until the condition will not become false Syntax :- while(condition):body of whileProgrami=20print("While loop start")while(i>10):print(i)i=i-1print("While loop ends")Output-While loop sta  ......

What is Break statement in python

By Yogesh on 31 Aug 22 | Filed under: Python
There are two type of loop in python -- for loop- while loop-At the time of execution of loop, if we want to terminate the loop before its actual termination point then we use break inside loop or we can say break is used to terminate the loop and resume the next instruction in the program.- break i  ......

Return list by function in python

By Yogesh on 31 Aug 22 | Filed under: Python
In function some times we need to return the value at back to the calling point of the function so that the return value is further used in program , generally in other programming like C language, we only return one value but in python we return number of values.- for returning the items we have a   ......

Write a program to add two numbers in python

By Yogesh on 31 Aug 22 | Filed under: Python
Program code#add two number by seperate functiondef add(a,b):return a+ba=int(input("Enter first numbern"))b=int(input("Enter second numbern"))#add and printprint("Sum is "+str(a+b))#add by function callingans=add(a,b)print("sum is "+str(ans))print(add(a,b))Output-Enter first number2Enter second numb  ......

How to add all number in list in python

By Yogesh on 31 Aug 22 | Filed under: Python
For calculating the sum of all numbers in the list in python, firstly we are aware of the list in python. list is mutable data type in python which hold a collection of items of different type.example -we have a list mylist=[1,2,3,4,5,6] and sum of all numbers in this list is :- 21 pr  ......

Increment and decrement operator in python

By Yogesh on 31 Aug 22 | Filed under: Python
In other programming language like C,C++, JAVA, we have a increment(++) and decrement(--) operator which increase and decrease the value respectively.example -a=3a++a will become 4a--a--a will become 2-But in python this type of operation is not validprogram -a=3a++print(a)a--a--print(a)output-   ......

What is "Set" in python

By Yogesh on 31 Aug 22 | Filed under: Python
Set in python are also similar as the list but in set items can never be repeated but in list items may repeated. Set is a immutable data type because in set , items value are not changes or index operation is not allowed.Even in set any kind of index operation is not allowed.Example of set:- S  ......

Type casting in python

By Yogesh on 26 Aug 22 | Filed under: Python
What is type casting -Conversion of one data type to another type is called type casting that means in programming at runtime we change the type of the data or variable which store data.Possible Type casting -int to floatfloat to intint to stringnumeric string to intlist to stringlist to setset to l  ......

List to string conversion in python

By Yogesh on 26 Aug 22 | Filed under: Python
String and list both are the different data type of different domain and structure of both data type is different. So when we want to convert list to string, we must aware of string as well as list in python.Example of conversion- List=['Hello','String']And we want to make a string which is loo  ......

String to list conversion in python

By Yogesh on 26 Aug 22 | Filed under: Python
String and list both are the different data type of different domain and structure of both data type is different. So when we want to convert string to list, we must aware of string as well as list in python.Example of conversion-String1='Mytext'And we want to make a list which is look like ´┐ŻList=  ......

What is List in python

By Yogesh on 23 Aug 22 | Filed under: Python
List is a mutable collection of the elements which belongs to different class of the data type, item in list are separated by comma (,) and list is enclosed in square brackets ([]),.List are very much similar to the array in c , but the major difference in both list and array in c is that item in li  ......

What is tuple in python

By Yogesh on 23 Aug 22 | Filed under: Python
Tuple in python also a sequence data type similar as list, item in tuple is separated by comma(,) and enclosed by parentheses.Tuple is immutable that means in tuple we can not modified the index value.Update is not allowed or addition new item are also not allowedTuple is read only listProgram-t=(1,  ......

What is Dictionary in python

By Yogesh on 08 Aug 22 | Filed under: Python
Python dictionary are the hash table type data. It arrangement are the two dimensional type or we can say each item contain two values ,one is key and another one is value corresponding to their keyDictionary is the mutable data typeEach item in dictionary are separated by the comma(,) and enclosed   ......

Explain String in Python

By Yogesh on 08 Aug 22 | Filed under: Python
String is a collection of characters, python provides simple and easy way to manage or manipulate the string. In Python, single character are also a string of length one and string in python are immutable.String is Immutable :-It means that at runtime we can not change the index value in the string   ......

Zip() function in python

By Pritvik on 05 Aug 22 | Filed under: Python
In Python, Zip() is an In-build function in which we pass two list as a argument and it will give or return the dictionary of python.Basically it take two list and take items of first list as a key and items of second list as a corresponding valuesExample - L1=[1,2,3]L2=[4,,5,6]ans= zip(L1,L2)h  ......

Range() function in Python

By Pritvik on 05 Aug 22 | Filed under: Python
Range in python is a in-build function which return the collection of sequential numbers started from the 0 by default up to specified range. It uses in python programming where we want to generate some sequential numbers.Example -range(4) will give 0,1,2,3range(1,5) will give 1,2,3,4range(5,1) will  ......

Write Hello World Program in Python

By Pritvik on 05 Aug 22 | Filed under: Python
In python 3, we have a print function for printing any string or statement on console. Here we are able to pass our string in single,double and triple quotation .i,e all three quotation are valid and we do not require to add a semicolon at the end of the line in python because python is a scripting   ......

Input in Python

By Pritvik on 05 Aug 22 | Filed under: Python
Python3 provide build-in function input() to take input or data from the user at the runtime of the program. python have print() function for display the data and input() for get the data, but here input() function have a capability of display and get the data from user side simultaneously.Syntax :   ......

Basic data type in python

By Vaibhav Shukla on 04 Aug 22 | Filed under: Python
Basic data type in Python-followings are the basic data type in python:-1. bool2. int 3. float4. str5. list6. set7. tuple8. dict BoolContain boolean values i.e. true or falseexample :- a=True print(a) // output - True ________________________________________Intcontain i  ......

Append and read in file handling in python

By Vaibhav Shukla on 04 Aug 22 | Filed under: Python
read()-- read() is a python file function which are used to read the existing file.Syntax-f=open('file.txt','r')f.read()-Here 'f' is the object which points the existing file.Append in file-Syntax-f=open('file.txt','a')f.write(string)-Here string is the content which we want to append into the file.  ......

write() and read() in file handling in python

By Vaibhav Shukla on 04 Aug 22 | Filed under: Python
read()-read() is a python file function which are used to read the existing file.Syntax-f.read()Here 'f' is the object which points the existing file.write()- write() is a python file function which are used to write in the file. If the file is not exist then write() function create new fi  ......

File handling in python

By Vaibhav Shukla on 04 Aug 22 | Filed under: Python
-Python supports file handling and allow users to handles the file.-user can easily perform many operation on file like read,write, modification etc.-the concept of file handling in python was inherit from the other old languages like c,c++.Open a file-Syntax-f=open(filename,mode)-Here filename is t  ......