
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

3K+ Views
Python is an object-oriented programming language. Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects.The variables that are defined outside the class can be accessed by any class or any methods in the class by just writing the variable name.Example# defined outside the class' # Variable defined outside the class. outVar = 'outside_class' print("Outside_class1", outVar) ''' Class one ''' class Ctest: print("Outside_class2", outVar) def access_method(self): print("Outside_class3", outVar) # Calling method by creating object uac = Ctest() uac.access_method() ... Read More

184 Views
Python provides many ways to create 2-dimensional lists/arrays. However, one must know the differences between these ways because they can create complications in code that can be very difficult to trace out.Example Live Demorows, cols = (5, 5) arr = [[0]*cols]*rows #lets change the first element of the 1st row to 1 & print the array arr[0][0] = 1 for row in arr: print(row) arr = [[0 for i in range(cols)] for j in range(rows)] #again in this new array lets change the 1st element of the first row # to 1 and print the array arr[0][0] = 1 for row in arr: print(row)Output[1, 0, 0, 0, 0] [1, 0, 0, 0, 0] [1, 0, 0, 0, 0] [1, 0, 0, 0, 0] [1, 0, 0, 0, 0] [1, 0, 0, 0, 0] [0, 0, 0, 0, 0] [0, 0, 0, 0, 0] [0, 0, 0, 0, 0] [0, 0, 0, 0, 0]

900 Views
A list is a collection which is ordered and changeable. In Python lists are written with square brackets. You access the list items by referring to the index number. Negative indexing means beginning from the end, -1 refers to the last item. You can specify a range of indexes by specifying where to start and where to end the range. When specifying a range, the return value will be a new list with the specified items.Example Live Demo# using list comprehension + sum() + list slicing # initializing list test_list = [3, 4, 1, 7, 9, 1] # printing original list print("The ... Read More

368 Views
A scatter plot is a type of plot or mathematical diagram using Cartesian coordinates to display values for typically two variables for a set of data. If the points are coded, one additional variable can be displayed.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_scatter.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() # Create a new Format object to formats cells in worksheets using #add_format() method . # ... Read More

233 Views
A radar chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_radar1.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() # Create a new Format object to formats cells in worksheets using #add_format() method . # here we create bold format object . bold = workbook.add_format({'bold': 1}) ... Read More

392 Views
A pie chart is a circular statistical graphic, which is divided into slices to illustrate numerical proportion. In a pie chart, the arc length of each slice, is proportional to the quantity it represents.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_pie.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() # Create a new Format object to formats cells in worksheets using #add_format() method . # here we create bold format object . bold ... Read More

334 Views
A line chart is a graphical representation of an asset's historical price action that connects a series of data points with a continuous line. This is the most basic type of chart used in finance and typically only depicts a security's closing prices over time.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_Line.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() # Create a new Format object to formats cells in worksheets using #add_format() method . # here we create ... Read More

232 Views
Donut Chart (also known as Doughnut chart) is a variation on a Pie chart except it has a round hole in the center which makes it look like a donut, hence the name. This empty space can be used to display additional data.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_doughnut1.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() # Create a new Format object to formats cells in worksheets using # add_format() method . # here we create ... Read More

231 Views
XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_styles.xlsx') #Show the styles for column and area chart types. chart_types = ['column', 'area'] for chart_type in chart_types: # The workbook object is then used to add new worksheet via the #add_worksheet() method. # Add a worksheet for each chart type worksheet = workbook.add_worksheet(chart_type.title()) # set zoom option worksheet.set_zoom(30) # ... Read More

369 Views
lsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_combined.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() # Create a new Format object to formats cells in worksheets using #add_format() method . # here we create bold format object . bold = workbook.add_format({'bold': True}) # Add the worksheet data that the charts will refer ... Read More