0% found this document useful (0 votes)
133 views4 pages

Python

Python is a dynamic, high-level and interpreted programming language that supports object-oriented programming. It can be used for web, enterprise and 3D applications. Variables in Python do not require data type declaration. Python's edit-test-debug cycle is fast as it does not require compilation. The main differences between Python 2 and 3 are in print statements, input functions, string handling and removal of the xrange function in Python 3. Python provides many features like being easy to learn, having a large standard library, and supporting GUI programming. Tkinter is commonly used to create Python GUIs and provides widgets like buttons, labels and menus. Geometry managers like pack, grid and place organize widgets on the window. Menus can be created
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
133 views4 pages

Python

Python is a dynamic, high-level and interpreted programming language that supports object-oriented programming. It can be used for web, enterprise and 3D applications. Variables in Python do not require data type declaration. Python's edit-test-debug cycle is fast as it does not require compilation. The main differences between Python 2 and 3 are in print statements, input functions, string handling and removal of the xrange function in Python 3. Python provides many features like being easy to learn, having a large standard library, and supporting GUI programming. Tkinter is commonly used to create Python GUIs and provides widgets like buttons, labels and menus. Geometry managers like pack, grid and place organize widgets on the window. Menus can be created
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Chapter1

1. What is Python?

 Python is a general purpose, dynamic, high level and interpreted programming language. It
supports Object Oriented programming approach to develop applications. It is simple and easy
to learn and provides lots of high-level data structures.

 Python is easy to learn yet powerful and versatile scripting language which makes it attractive
for Application Development

 Python supports multiple programming pattern, including object oriented, imperative and


functional or procedural programming styles

2. Why python is known as multipurpose?

 because it can be used with web, enterprise, 3D CAD etc.

3. In python why We don't need to use data types to declare variable?

 because it is dynamically typed so we can write a=10 to assign an integer value in an integer
variable.

4. Why python makes the development and debugging fast?

  because there is no compilation step included in python development and edit-test-debug cycle
is very fast.

5. What is the difference b/w Python2 & Python3?

 Python 2 uses print as a statement and used as print "something" to print some string on the
console. On the other hand, Python 3 uses print as a function and used as print("something") to
print something on the console.

 Python 2 uses the function raw_input() to accept the user's input On the other hand, Python 3
uses input() function which automatically interpreted the type of input entered by the user

 In python 2, the implicit string type is ASCII whereas, in python 3, the implicit string type is
Unicode.

 Python 3 doesn't contain the xrange() function of python 2. The xrange() is the variant of range()
function which returns a xrange object that works similar to Java iterator

6. Python provides lots of features list and explain them?


 Easy to Learn and Use: Python is easy to learn and use. It is developer-friendly and high level
programming language.

AxssanBoy
 Expressive Language: Python language is more expressive means that it is more understandable
and readable.
 Interpreted Language: Python is an interpreted language i.e. interpreter executes the code line by
line at a time. This makes debugging easy and thus suitable for beginners.
 Cross-platform Language: Python can run equally on different platforms such as Windows, Linux,
Unix and Macintosh etc. So, we can say that Python is a portable language.
 Free and Open Source: Python language is freely available at offical web address.The source-code
is also available. Therefore it is open source.
 Object-Oriented Language: Python supports object oriented language and concepts of classes and
objects come into existence.
 Extensible: It implies that other languages such as C/C++ can be used to compile the code and
thus it can be used further in our python code.
 Large Standard Library: Python has a large and broad library and prvides rich set of module and
functions for rapid application development.
 GUI Programming Support: Graphical user interfaces can be developed using Python.
 Integrated: It can be easily integrated with languages like C, C++, JAVA etc.
7. List the applications that we can apply in python?
 Web Applications
 Desktop GUI Applications
 Software Development

Chapter2

1. List stpes that can be used to create an empty Tkinter top-level window?
 import the Tkinter module.
 Create the main application window.
 Add the widgets like labels, buttons, frames, etc. to the window.
 Call the main event loop so that the actions can take place on the user's computer screen.
2. List the widgets that are used to build the python GUI applications?
 Button: The Button is used to add various kinds of buttons to the python application.
 Canvas: The canvas widget is used to draw the canvas on the window.
 Checkbutton: The Checkbutton is used to display the CheckButton on the window.
 Entry: The entry widget is used to display the single-line text field to the user. It is commonly
used to accept user values.
 Label: A label is a text used to display some message or information about the other widgets.
 ListBox: The ListBox widget is used to display a list of options to the user.
 Message: The Message widget is used to display the message-box to the user
 Radiobutton: The Radiobutton is different from a checkbutton. Here, the user is provided
with various options and the user can select only one option among them.
3. What is the Tkinter geometry ?
 The Tkinter geometry specifies the method by using which, the widgets are represented on
display.

AxssanBoy
4. List and explain geometry methods of python Tkinter?
 The pack() method: is used to organize widget in the block
 Syntax: widget.pack(options)  
 The grid() method: organizes the widgets in the tabular form. We can specify the rows and
columns as the options in the method call
 Syntax: widget.grid(options)  
 The place() method: organizes the widgets to the specific x and y coordinates.
 Syntax: widget.place(options)  
 A list of possible options that can be passed in pack() is given below:
 expand: If the expand is set to true, the widget expands to fill any space.
 Fill: By default, the fill is set to NONE
 size: it represents the side of the parent to which the widget is to be placed on the
window.
 A list of possible options that can be passed inside the grid() method is given below:
 Column: The column number in which the widget is to be placed. The leftmost column is
represented by 0.
 Columnspan: The width of the widget. It represents the number of columns up to which, the
column is expanded.
 ipadx, ipady: It represents the number of pixels to pad the widget inside the widget's border.
 padx, pady 
It represents the number of pixels to pad the widget outside the widget's border.
 Row:The row number in which the widget is to be placed. The topmost row is represented by 0.
 Rowspan: The height of the widget, i.e. the number of the row up to which the widget is
expanded.
 Sticky: If the cell is larger than a widget, then sticky is used to specify the position of the widget
inside the cell
 A list of possible options that can be passed place() method is given below:
 Anchor: It represents the exact position of the widget within the container. The default value
(direction) is NW (the upper left corner)
 bordermode: The default value of the border type is INSIDE that refers to ignore the parent's
inside the border. The other option is OUTSIDE.
 height, width: It refers to the height and width in pixels.
 relheight, relwidth: It is represented as the float between 0.0 and 1.0 indicating the fraction of
the parent's height and width.
 relx, rely: It is represented as the float between 0.0 and 1.0 that is the offset in the horizontal
and vertical direction.
 x, y: It refers to the horizontal and vertical offset in the pixels.
o Python provides the standard library for creating the graphical user interface for desktop based
applications.

AxssanBoy
Chapter3
Note
 The Menu widget is used to create various types of menus (top level, pull down, and pop up) in the
python application.
 The top-level menus are the one which is displayed just under the title bar of the parent window.
We need to create a new instance of the Menu widget and add various commands to it by using the
add() method.
 The Menubutton widget can be defined as the drop-down menu that is shown to the user all the
time. It is used to provide the user a option to select the appropriate choice exist within the
application.
 The Menubutton is used to implement various types of menus in the python application
Practice

#Create form named ‘test’?

 from tkinter import *


 test=Tk()

#Add label named ‘id’ to the form with position=0,0

 lbl=Label(test,text="id").grid(row=0,column=0)

#Add entry(textbox) to the form with position=0, 1

 ent=Entry(test).grid(row=0,column=1)

#Add Button named ‘save’ to the form with position=3,1

 btn=Button(test,text="save").grid(row=3,column=1)

#create  toplevel menu  to the form

 menubar = Menu(test)  

#Add sub-menu to the menubar

 file = Menu(menubar, tearoff=0) 

 file.add_command(label="New")  

 file.add_command(label="Open")  

 file.add_command(label="Save")  

#Add separator to the menubar

 file.add_separator()  

#display the menu  

 menubar.add_cascade(label="File", menu=file)  

 test.config(menu=menubar)  

AxssanBoy

You might also like