Skip to main content

Writing a program

Typing commands into the Python interpreter is a great way to experiment with Pythons features, but it is not recommended for solving more complex problems. When we want to write a program, we use a text editor to write the Python instructions into a file, which is called a script. By convention, Python scripts have names that end with .py.
To execute the script, you have to tell the Python interpreter the name of the file. In a UNIX or Windows command window, you would type python hello.py as follows:
csev$ cat hello.py
print 'Hello world!'
csev$ python hello.py
Hello world!
csev$
The “csev$” is the operating system prompt, and the “cat hello.py” is showing us that the file “hello.py” has a one line Python program to print a string. We call the Python interpreter and tell it to read its source code from the file “hello.py” instead of prompting us for lines of Python code interactively. You will notice that there was no need to have quit() at the end of the Python program in the file. When Python is reading your source code form a file, it knows to stop when it reaches the end of the file.

Comments

Popular posts from this blog

connection oriented

connection-oriented:- connection-oriented  describes a means of transmitting data in which the devices at the end points use a preliminary  protocol  to establish an end-to-end connection before any data is sent. Connection-oriented protocol service is sometimes called a "reliable" network service, because it guarantees that data will arrive in the proper sequence. Transmission Control Protocol ( TCP ) is a connection-oriented protocol. For connection-oriented communications, each end point must be able to transmit so that it can communicate. The alternative to connection-oriented transmission is the  connection-less  approach, in which data is sent from one end point to another without prior arrangement. Connection-less protocols are usually described as  stateless  because the end points have no protocol-defined way to remember where they are in a "conversation" of message exchanges. Because they can keep track of a conversation, connection-or...

Cloud Computing architecture

Cloud computing architecture refers to all components and sub-components that together form the structure of the cloud computing system. This architecture can be divided into three parts for better understanding – front end, back end and middleware. Each part of the cloud architecture has its own set of functionalities and protocols that work together to deliver on-demand services to user-facing hardware as well as software. In general, the architecture is evolved out of large distributed network applications over the last two decades. Hence it supports any system where resources can be pooled and partitioned as required. The general cloud architecture is capable of running multiple software applications running on multiple virtual hardware in multiple locations to efficiently render on-demand services to the users. The users could be using these software applications from their desktop or laptop or mobile or tablets. Usually, whatever the user is looking at – through t...

What is technical analysis?

 Technical Analysis (also abbreviated as TA) is a popular technique that allows you to do just that. It not only helps you develop a point of view on a particular stock or index but also helps you define the trade keeping in mind the entry, exit and risk perspective.  Like all research techniques, Technical Analysis also comes with its own attributes, some of which can be highly complex. However, technology makes it easy to understand. Technical Analysis is a research technique to identify trading opportunities in market based on the actions of market participants. The actions of market participants can be visualized by means of a stock chart. Over time, patterns are formed within these charts and each pattern conveys a certain message. The job of a technical analyst is to identify these patterns and develop a point of view. Like any research technique, technical analysis stands on a bunch of assumptions. As a practitioner of technical analysis, you need to trade the markets k...

tag