InterviewSolution
| 1. |
Python Commands |
|
Answer» Magic Commands are one of the new features added to the python shell. Basically, they are enhancements over the normal python code, provided by the IPython Kernel. The main syntax for these commands is that they are prefixed by as “%” character. They prove useful in solving many common problems we encounter while coding and also provide us some versatile shortcuts.
Some examples of these commands in Python are:
print("Hello World") runner() %run runner.py Output: Hello World
for i in range(10000): a = a + i**2 Output: CPU Times: user: 3.72 ms, sys: 9us, , total: 3.73ms, Wall time: 3.75ms
def func(): print("Hello") func() Output: Overwriting code.py
def func(): print("Hello") func()
b = 5 c = 1 %who Output: a b c
<html> <body> <table> <tr> <th>Name</th> <th>Country</th> <th>Age</th> </tr> <tr> <td>Sid</td> <td>India</td> <td>22</td> </tr> <tr> <td>Dave</td> <td>UK</td> <td>28</td> </tr> </table> </body> </html> Output:
Some other useful tools for Python
We can conclude that Python is a robust, high-level, interpreted programming language. It is also an Object Oriented Programming Language that strongly follows all OOPs principles. It has various inbuilt powerful modules that follow simple syntax which makes it appealing to both beginners and experienced folks alike. A vast collection of libraries and functions makes the development of any sort much easier in Python. In this cheat sheet, we have covered the most common fundamentals of python language that would help you kickstart your career in python. Useful Resources:
|
|