Python is a relatively new language which is great for beginning programmers and a language used in many real-world projects as well. The following are its key ingredients:
1. Login to Linux with your user name and password.
2. Open a term window: From Fedora Applications, select System | Terminal.
3. Enter "python" at the prompt. This will start the Python interactive interpreter.
With the interpreter, you can try individual python commands and quickly
learn the syntax of the language.
4. When you enter 'python' you should see the python prompt >>>.
This is asking you to enter python commands. Type in the following to see
what happens:
print 'hello'.
print 3*6
print 3/6
print 3.0/6.0
print 2+4*2
money=324.56
interestRate=0.1
oneYearReturn=money*interestRate
print oneYearReturn
print 'abc'+'def'
first='david'
last='wolber'
print first+' '+last
x = 5
print x*7
print 'x'*7
type (x)
type ('x')
type (3)
type (3.4)
type ( ['a','b','c'] )
list =['a','b','c']
list[1]
list[2]=44
list
1. Why does 3/6=0
2. What is the value of 2+4*2? Why?
3. Python lets you add strings, e.g., 'abc'+'xyz'. What does '+' do?
4. In programming terms, what is 'money'?
4. What is the result of 'x'*7
5. What does the 'type' command do?
6. What is a type?
7. What types did you explore above?
8. Are python lists homogeneous or heterogeneous?
9. Can Python lists grow?
You can also write a program in a file and run the whole thing at
once. Open the wysiwyg editor called Text Editor
(Choose Fedora Applications, Accessories | Text Editor). Then do the following:
1. Create a new file and enter the following statements:
print "hello"
print "world"
name = "jive"
print name
2. Save the file as hello.py
3. Back at the terminal window, enter:
python hello.py
The following should print:
hello
world
jive