Posts

List in Python | Adding item | Removing item | Length of List | Frequency of an Element |Sorting of list |Conversion from list to string

Creating list list1 = ["first","second","Third"] print(list1) list2 = [1,2,3,4] print(list2) Accessing elements of list We should keep in mind that first element in a list is referred as the 0th element second as 1st and so on. X = list1[0] Y = list2[0] print(X) print(Y) Changing element value   list1[1] = "forth"  #position of element is given list2[2] = 4 Adding element in list At last of list list1.append("fifth") list2.append(5) At specific position listname.append(position,value) list1.insert(3,"sixth") list2.insert(3,6) Removing element of a list Using list.remove()  this method remove element with its value list1.remove("second") list2.remove(2) using pop() method this method remove element at specified position.If position is not mentioned method will remove the last element. list1.pop(2) list2.pop(3

String in Python | Function related to string in Python

Image
Initializing string in Python X = "some string"             or X = 'some string' print(x) Getting character at a specified position X = "some string" Y = X[0]  # position in big brackets 1 st character is treated as 0th position print(Y) For getting character from back we have to mention -ve sign z = X[-1] print(z) Getting a set of character from string For getting a set of  a character from index a to index b we have to use X= "some string" Y = X[a:b] # b will be excluded Y = X[5:8] Getting length of string X = "some string" Y = len(X) print(y) Converting text into lower case or upper case using x.lower() X = "SOME string" y=x.lower() print(y) Using x.upper X = "some string" Y = x.upper print(y) Removing space from start or end of a string Using strip X = "   some str

Project in Python | Encryption and Decryption

Image
Download Source code Link Here

Casting in Python | Conversion of datatypes

Image
Casting in python Casting is conversion of value of a variable from one data type to other example -- Converting   X = 3  ( is a integer) to X = 3.0 (is a float) There are basically three types of data type Casting into integer. Casting into string. Casting into float. Casting into integer Casting float into integer or casting string into integer provided the content of string is a whole number We use int() for this type of casting. X = int(3.5)            #value of x will be 3 Y= int ("3")            #value of y will be treated as integer and we can perform arithmetic operation Z = int("hello")  #this will throw error the value is not whole number Casting into string Casting float into string or casting integer into string We use str() constructor for casting.  X = str(3)  # 3 will be considered as string and arithmetic operation can't be done Y = str(3.0) #3.0 will be considered as string  and arithme

Variables in Python | Data Types | Rules For declaring variable |Storing and Printing the value of variable | Operation in variable

Image
What are variable As the name suggest a variable is entity whose value can be changed any time you want. In other programming language like C,C++,Java we have a special command to declare variable.In these language we also have to mention the type of value variable is storing whether its Integer,characters or decimal. But don't worry its python you don't need any command to declare a variable.Its declared when you first equate the value to a variable. X = 5              (X is treated as integer) Y = "Hello"    (Y is treated as string due to " ") Z = 5.6            (Z is treated as decimal) Datatype Data type refer to the type of value a variable is storing There are basically three type of datatype Integer --- These contains integral Data 5,4,47,100.We can     apply mathematical operation to these String  ---- These datatype contains words characters any    entity surrounded by "  " will be consider as   string

Hello world | Comments in Python | Escape character | Example | Practical Question

Image
Hello coders, Today we will learn to print Hello world,How to use comments in python ,Escape character,How to live a line,\n,\t,\r,Finally we will go through some practical question. Printing in Python print("hello world") Run an Online python compiler Here  and test it. Not only hello world but you can print any text in python console use print keyword. print("any text here") Printing Hello World In Python Comments in Python | why we need comments   Suppose you are writing  a Python program which is very vast.You can't remember why you have used that piece of code.Here comes the use of comment. Or suppose you have to present this code to a non technical person then you can use comments to specify why you have written that piece of code. Comments are not executed by compiler. ''' your comments go here''' Use of comment --- '' Below code is used to print hello world''&#

What is Programming | Programming Language | Compiler | Why Python

Hello Coders, Here we are with new series of python.                                       Programming Programming is a art to convert a idea into set of instruction(program) a Computer can follow. Person converting idea into set of instruction is called Programmer. Medium of giving instruction is known as Programming language.                                                                   Programming Language Programming Language is a method by which a coder give set of instruction to computer to perform a specific task or make a Software. There are two types of programming language Low level programming language High Level programming language                                    Low Level Language These Language are closer to Computer's native language 0's and 1's. They don't need any medium (compiler or interpreter) to convert code into machine language that's why their processing is fast. They uses less memor