<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction to Python
In this chapter, you will start testing your python by $\mathbf X$<br>
1. printing basic operations,
2. defining different variable types,
3. looking into lists of objects,
4. making decisions with conditions,
5. iterating with for loops and
6. defining some basic functions.
1. Basic Syntax
Step1:  You can find more examples at LearnPython & PythonTutorial.
2. Variable Types
You are automatically defining a variable type while initializing the variable such as
Step2:  You may separate commands using ";"
Step3:  print myfloat1
Step4:  This is a box of comments
You may define strings differently, and attach them using "+". You can remove a variable from the memory when you do not need, using "del"
Step5:  3. Lists
List a special case of array, except they can include variables with different types. You can easily append, delete, merge, different lists. You can even exchange the index number with a string as a name. List is one of the most useful objects in Python.
Index in list starts from zero (0) unlike R. 
A string is actually a list. 
-1 shows the end of the list but the last. 
Range of indices is like [start, end[ so you do not get access to the last element.
Step6:  Here is a simple example that shows how a list is different with an array.
Step7:  Exercise <br>
Make two lists. First, a list of 4 of your best friends' first name.
Second, a list of their family name. Then print their first name and last name.
Step8:  You may insert several other elements to the list using "append", "insert", "index" and several others. See below for for more details
python
list.append(x)
Add an item to the end of the list; equivalent to a[len(a)
Step9:  Lines and Indentation
Python provides no braces to indicate blocks of code for class and function definitions or flow control. Blocks of code are denoted by line indentation, which is rigidly enforced.
The number of spaces in the indentation is variable, but all statements within the block must be indented the same amount.
Step10:  5. For Loop
The "for" loops iterate over a given sequence. <br>
The "range" function is a very useful command in loops.
Step11:  Exercise <br>
Create a new list in the form of firstname_lastname of your 5 friends.
6. Function definition
The "def" command, can be used to define a function.
Step12:  Exercise  <br>
Define a function that gives the square of a list elements.
<ASSISTANT_TASK:>
Python Code:
#a = 2
#b = 1
a, b, c = 2, 3, "Hello World!"
#print a # works in python2 but not python3
print( a )
print ("Hello World!")
print (3*3)
print (3**2)
print (2+2)
Explanation: Introduction to Python
In this chapter, you will start testing your python by $\mathbf X$<br>
1. printing basic operations,
2. defining different variable types,
3. looking into lists of objects,
4. making decisions with conditions,
5. iterating with for loops and
6. defining some basic functions.
1. Basic Syntax
End of explanation
myint = 7
myfloat1 = 7.0; myfloat2 = float(7)
Explanation: You can find more examples at LearnPython & PythonTutorial.
2. Variable Types
You are automatically defining a variable type while initializing the variable such as
End of explanation
print (myint/2); print (myfloat1/2); print (myfloat2*2); print (myfloat2**2)
Explanation: You may separate commands using ";"
End of explanation
mystring1 = 'Hello'
# in R mystring1 <- 'Hello'
mystring2 = "World"
mystring12 = mystring1+" "+mystring2+"!"+"?"+"!"
#add a comment
print (mystring12)
Explanation: print myfloat1
End of explanation
dir()
del mystring1, mystring2
dir()
print (mystring12)
print (len(mystring12))
print (mystring12 * 2)
print (3.0 / 2)
print (3 / 2.)
print (3 / 2)
Explanation: This is a box of comments
You may define strings differently, and attach them using "+". You can remove a variable from the memory when you do not need, using "del"
End of explanation
print (mystring12)
print (mystring12[0])
print (mystring12[1:2])
# 1:n [1:n]
print (mystring12[:])
mylist = [1, 2, 3.]
print (mylist)
print (mylist[0])
Explanation: 3. Lists
List a special case of array, except they can include variables with different types. You can easily append, delete, merge, different lists. You can even exchange the index number with a string as a name. List is one of the most useful objects in Python.
Index in list starts from zero (0) unlike R. 
A string is actually a list. 
-1 shows the end of the list but the last. 
Range of indices is like [start, end[ so you do not get access to the last element.
End of explanation
mylist = [1, 2, 3, "2", "Hello World", [1, 2, 3] ]
print (mylist)
print (mylist[-1])
print (mylist[2]*3)
Explanation: Here is a simple example that shows how a list is different with an array.
End of explanation
firstname= ["Mansoore","Shakib", "Mahdi","Somayeh"]
lastname=["Razmkhah", "Panah", "Alehdaghi","Noshadi"]
print (firstname)
print (lastname) 
#The "zip" function pairs several lists of the same size.
firstlast = zip(firstname, lastname)
print (list(firstlast))
Explanation: Exercise <br>
Make two lists. First, a list of 4 of your best friends' first name.
Second, a list of their family name. Then print their first name and last name.
End of explanation
x = 2
print (x == 2) 
print (x < 2)
print (not x < 2)
print( (x == 2)*(x > 1) )
a = 0
if a == 0:
    print( "a equals zero" ) # do not use a is equal to zero (bad English) 
else:  
    print( "a is non-zero" ) # do not use a is not equal to zero (bad English) 
if x==2:
    print( "x equals two" )
else:
    print( "x differs" )
Explanation: You may insert several other elements to the list using "append", "insert", "index" and several others. See below for for more details
python
list.append(x)
Add an item to the end of the list; equivalent to a[len(a):] = [x].
python
list.extend(L)
Extend the list by appending all the items in the given list; equivalent to a[len(a):] = L.
python
list.insert(i, x)
Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list, and a.insert(len(a), x) is equivalent to a.append(x).
python
list.remove(x)
Remove the first item from the list whose value is x. It is an error if there is no such item.
python
list.pop([i])
Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.)
python
list.index(x)
Return the index in the list of the first item whose value is x. It is an error if there is no such item.
python
list.count(x)
Return the number of times x appears in the list.
python
list.sort(cmp=None, key=None, reverse=False)
Sort the items of the list in place (the arguments can be used for sort customization, see sorted() for their explanation).
python
list.reverse()
Reverse the elements of the list, in place.
Exercise <br>
Add your new friend: <br> 
1. As the first element, 
2. as the last element, 
3. in the middle.
4. Conditions
Python uses boolean variables to evaluate conditions. Tab separates different code blocks, therefore there is no need for brackets.
End of explanation
print( firstname )
if "John" in firstname:
  print "John is in the list"
Explanation: Lines and Indentation
Python provides no braces to indicate blocks of code for class and function definitions or flow control. Blocks of code are denoted by line indentation, which is rigidly enforced.
The number of spaces in the indentation is variable, but all statements within the block must be indented the same amount.
End of explanation
print( range(10) )
print( range(2,6) )
print( range(2,14,4) )
print( range(len(firstname)))
for i in range(len(firstname)):
    print( firstname[i] )
for name in firstname:
    print( name )
Explanation: 5. For Loop
The "for" loops iterate over a given sequence. <br>
The "range" function is a very useful command in loops.
End of explanation
def sq(x):
    return x**2
print( sq(75) )
Explanation: Exercise <br>
Create a new list in the form of firstname_lastname of your 5 friends.
6. Function definition
The "def" command, can be used to define a function.
End of explanation
def sqlist1(X):
    return [sq(x) for x in X]
sqlist1(range(6))
def sqlist2(X):
    Y=[0]*len(X)
    for i in range(len(X)): 
        Y[i]=sq(X[i])
    return Y
sqlist2(range(6))
Explanation: Exercise  <br>
Define a function that gives the square of a list elements.
End of explanation
<END_TASK>