Posts

Showing posts with the label python3 tutorial

Strings and list in python

Strings: If alphanumeric characters are enclosed in single or double quotation marks, it indicates a string. For example, S1='hello' S2='hai' Print (type (S1)) #and your output will be  str Indexing: It is used to extract a single character from a string. For example, S='hello' print (S[1]) #and your output will be  e #e is present in the location given in input Slicing: It is used for printing a subset of the string. For example, S='Good day' print (S[0:3]) #and your output will be  Goo #the characters present from 0th to 2nd(n-1) position is printed Other functions: 1)len(S) -Used to find the length of the string .i.e.the number of characters in the string. 2)lower(S) -Used to print the string in lower case. 3)upper (S) -Used to print the string in upper case. 4)replace (S) -Used to replace the characters in a string. Sample problems: Problem-1 To reverse a string Input S='Good day' k=S[::-1] print (k) # here S[-1]=y Output yad dooG Problem-2 T

Introduction to python(Installation of python,Python libraries,ASCII values,input and output statements)

Image
                                           Installation of python: Python is installed from c:\python27 Path variable has to be set in python file, inorder to run the program. Python features: Python is very supportive for data analytics. It has general public licence (GPL). It is a scripting language. It is an object oriented programming language. It is an open source language. Python libraries: NLP package. PIL(Python Image Library). Math Functions: 1)print() Use:It is used to print a statement or variable. Example: print ("hello world") Output: hello world 2)Data types: int           It includes all integers.eg.5,9,23 etc float           It includes all decimal values.eg. 2.7 ,4.0 etc str           It includes a group of alphabets.eg. hello ,won etc 3) type () Use:It is used to declare the data type. Example: X=3.0 Y=5 Z=X+Y A=hello print (type(X)) print (type(Y)) print (type(A)) Output: Float Int String 4)type conversion: The expression of one data type on other is called