0% found this document useful (0 votes)
108 views2 pages

1.2.1. First Steps: "Hello, World!"

The document discusses getting started with Python by opening the Ipython shell and running basic commands like print "Hello, world!". It then provides an example of defining variables, changing their types, and performing operations on integers and strings. Variables in Python do not require declaring a type and their type can change based on the value assigned. Operations are supported natively for both integers and strings.

Uploaded by

Manu Mannu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views2 pages

1.2.1. First Steps: "Hello, World!"

The document discusses getting started with Python by opening the Ipython shell and running basic commands like print "Hello, world!". It then provides an example of defining variables, changing their types, and performing operations on integers and strings. Variables in Python do not require declaring a type and their type can change based on the value assigned. Operations are supported natively for both integers and strings.

Uploaded by

Manu Mannu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

11/16/2014

1.2.1. First steps Scipy lecture notes

1.2.1. First steps


Start the Ipython shell (an enhanced interactive Python shell):
by typing ipython from a Linux/Mac terminal, or from the Windows cmd shell,
or by starting the program from a menu, e.g. in the Python(x,y) or EPD menu if you
have installed one of these scientific-Python suites.
If you dont have Ipython installed on your computer, other Python shells are available, such as the
plain Python shell started by typing python in a terminal, or the Idle interpreter. However, we advise
to use the Ipython shell because of its enhanced features, especially for interactive scientific
computing.

Once you have started the interpreter, type


>>> print "Hello, world!"
Hello, world!

>>>

The message Hello, world! is then displayed. You just executed your first Python instruction,
congratulations!

To get yourself started, type the following stack of instructions


>>> a = 3
>>> b = 2*a
>>> type(b)
<type 'int'>
>>> print b
6
>>> a*b
18
>>> b = 'hello'
>>> type(b)
<type 'str'>
>>> b + b
'hellohello'
>>> 2*b
'hellohello'

>>>

Two variables a and b have been defined above. Note that one does not declare the type of an
variable before assigning its value. In C, conversely, one should write:
int a = 3;
In addition, the type of a variable may change, in the sense that at one point in time it can be equal to
a value of a certain type, and a second point in time, it can be equal to a value of a different type. b
was first equal to an integer, but it became equal to a string when it was assigned the value 'hello' .
Operations on integers ( b=2*a ) are coded natively in Python, and so are some operations on strings
http://scipy-lectures.github.io/intro/language/first_steps.html

1/2

11/16/2014

1.2.1. First steps Scipy lecture notes

such as additions and multiplications, which amount respectively to concatenation and repetition.

http://scipy-lectures.github.io/intro/language/first_steps.html

2/2

You might also like