I think every one of us is aware of the “Hello World” Program, that you script when you master a language like Python.
Open Your Start Menu and select Python command Line.
You will see a line like >>>
With this, you can do everything in a communicative, and Interactive mode in Python Interpreter. Where >>> come in. Moreover, Python Shows you >>>, when you are going to type something in the command line.
At the prompt, type the below line, use only single Quote at the start and end, it’s beside the Enter key.
Then press the Enter Key.
Python Runs the code, that you type.
You can see the Output, as below, I think, if you write this program for the first time, then this is your first program and Output.
Python 2.7.9 < default, Dec 2019, 05:43:54> [MSC V.1500 32 bit <intel>] on win 32
Type “help”, “copyright” or “license” for more information.
>>> print<‘ hello world ’> Hello, world! >>> _ If you dint see the Above Output, on your System, in the same way, do the following.
Check what you have typed from step 2.
The Single Quotes and Parentheses in the right positions.
Check, in the same way for every opening parenthesis, that there is a closing Parenthesis, that you left hanging.
Check for Every Opening Quote, there is a closing Quote.
Every Programming language, have Inbuilt Own reference and Grammar Rules. Moreover, These Rules, are known as Language Syntax.
Finish Your Lab Work
Generally, we do fractions in our Python Lab. Use those Fractions, method and fraction Object, that select the Digit and Numerator.
For getting the One-half, type fractions.fraction(1,2). For four-fifths, type fractions.fraction(4,5):
>>> import fractions >>> one_half = fractions.Fraction(1, 2) >>> one_fifth = fractions.Fraction(1, 5)
With fractions, we do normal fraction calculations
Generally, every one of us knows, programming is an important skill. As a matter of fact, the below are the code words of Python, built-ins, set library functions, operators, that you use most when you do programming with Python.
And – Logical Operator, for testing two things, whether they are true or not.
As – Assign a File object to a Variable, similarly if your code differs from a unit under a different name, that used with Import.
Break – It stops Executing a Loop.
Python Widgets are Set Graphical User Interface Elements, similarly many buttons, and menus.
Option Menu Widget
Especially, Options Menu Widget will let you select, from a list of options. That is for using the Options menu, in the right way. In the same fashion, You may bind it to a separate call back. That which update, other Data, which is based on user selection.
import Tkinter parent_widget = Tkinter.Tk() control_variable = Tkinter.StringVar(parent_widget) OPTION_TUPLE = ("Option 1", "Option 2", "Option 3") optionmenu_widget = Tkinter.OptionMenu(parent_widget, control_variable, *OPTION_TUPLE) optionmenu_widget.pack() Tkinter.mainloop()
Generally, With the menu Widget, you can Design a Menu bar. Designing menus is hard. If you concentrate on Drop-Down Menus. Consequently, Doing that, you can use a Separate menu, widget for every Drop down menu when you design it.
import Tkinter parent_widget = Tkinter.Tk() def menu_callback(): print("I'm in the menu callback!") def submenu_callback(): print("I'm in the submenu callback!") menu_widget = Tkinter.Menu(parent_widget) submenu_widget = Tkinter.Menu(menu_widget, tearoff=False) submenu_widget.add_command(label="Submenu Item1", command=submenu_callback) submenu_widget.add_command(label="Submenu Item2", command=submenu_callback) menu_widget.add_cascade(label="Item1", menu=submenu_widget) menu_widget.add_command(label="Item2", command=menu_callback) menu_widget.add_command(label="Item3", command=menu_callback) parent_widget.config(menu=menu_widget) Tkinter.mainloop()
Functions are known as best and most powerful tools, in programming toolbox. Because they accept, you to separate your program, into best and meaningful blocks.
Every Plug-in in Python, functions is from the Set library.
The Rules for naming a Function is like naming a Variable.
It is lengthier, but we should arrange them shorter.
They have Numbered.
Functions should be Lower case.
They have to start with underscore or Letters.
Functions are Not python keywords. In the same way, they will have the same name as the Existing function, but we have to avoid this as of Now.
I think this Blog will help you in, how you can Code in python and, up to my knowledge, coding is simple when we master the basics of any programming language. Just like alphabets in the English Language. For Every Language Fundamentals are Important.
If you want more techniques, go for Free Python Online Training Demo.