In [1]:
full_name = "Hrant Davtyan"

In [2]:
type(full_name)


Out[2]:
str

In [4]:
full_name[-1]


Out[4]:
'n'

In [6]:
full_name[:5]


Out[6]:
'Hrant'

In [7]:
name = "Grant"

In [8]:
name[0]


Out[8]:
'G'

In [9]:
name[0] = "H"


-------------------------------------------------------
TypeError             Traceback (most recent call last)
<ipython-input-9-5b593c8efe5b> in <module>()
----> 1 name[0] = "H"

TypeError: 'str' object does not support item assignment

In [10]:
names = ["Hrant"]

In [11]:
names[0]


Out[11]:
'Hrant'

In [12]:
names[0] = "Grant"

In [13]:
my_tuple = ("Hrant","Davtyan")

In [14]:
type(my_tuple)


Out[14]:
tuple

In [15]:
stock_name = input()


IBM
-------------------------------------------------------
NameError             Traceback (most recent call last)
<ipython-input-15-d4f226949916> in <module>()
----> 1 stock_name = input()

C:\ProgramData\Anaconda2\lib\site-packages\ipykernel\ipkernel.py in <lambda>(prompt)
    162             self._sys_eval_input = builtin_mod.input
    163             builtin_mod.raw_input = self.raw_input
--> 164             builtin_mod.input = lambda prompt='': eval(self.raw_input(prompt))
    165         self._save_getpass = getpass.getpass
    166         getpass.getpass = self.getpass

C:\ProgramData\Anaconda2\lib\site-packages\ipykernel\ipkernel.py in <module>()

NameError: name 'IBM' is not defined

In [16]:
stock_name = raw_input()


IBM

In [17]:
print(stock_name)


IBM

In [18]:
int("5")


Out[18]:
5

In [19]:
import this


The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

In [21]:
my_names = ["Jack","James","Jimmy"]
for k in range(len(my_names)):
    print(my_names[k])


Jack
James
Jimmy

In [22]:
for i in my_names:
    print(i)


Jack
James
Jimmy

In [23]:
print(my_names)


['Jack', 'James', 'Jimmy']

In [24]:
my_names.head()


-------------------------------------------------------
AttributeError        Traceback (most recent call last)
<ipython-input-24-a086bffbc221> in <module>()
----> 1 my_names.head()

AttributeError: 'list' object has no attribute 'head'

In [25]:
my_names.append("John")

In [26]:
print(my_names)


['Jack', 'James', 'Jimmy', 'John']

In [27]:
new_list = []

In [28]:
type(new_list)


Out[28]:
list

In [29]:
len(new_list)


Out[29]:
0

In [31]:
for i in range(10):
    new_list.append(i)

In [32]:
print(new_list)


[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

In [33]:
empty_list = []
for i in range(5):
    empty_list.append(str(i))

In [34]:
print(empty_list)


['0', '1', '2', '3', '4']

In [35]:
0+1


Out[35]:
1

In [36]:
"0"+"1"


Out[36]:
'01'

In [37]:
i=0
while i<5:
    print(i)
    i = i + 1


0
1
2
3
4

In [38]:
j = 0
while j<len(my_names):
    print(my_names[j])
    j = j + 1


Jack
James
Jimmy
John

In [39]:
if 5<7:
    print("Yes!")


Yes!

In [40]:
if 5>7:
    print("Yes!")

In [41]:
if 5>7:
    print("It is bigger!")
else:
    print("It is not bigger!")


It is not bigger!

In [42]:
if 5>7:
    print("5 is bigger!")
elif 5<7:
    print("5 is less!")
else:
    print("They are equal!")


5 is less!

In [43]:
if 5>7:
    print("5 is bigger!")
elif 5==7:
    print("They are equal!")
elif 5==6:
    print("They are equal!")
elif 5==5:
    print("They are equal!")
else:
    print("5 is less!")


5 is less!

In [ ]: