#!/usr/bin/env python
# coding: utf-8

# In[9]:


def printeven(n):
    cnt=0
    sum=0
    while(cnt<=n):
        if(cnt%2==0):
            sum=sum+cnt
        cnt=cnt+1
    return sum
print(printeven(20))


# ## Sum of even numbers

# In[11]:


def factors(n):
    i=1
    while(i!=n):
        if(n%i==0):
            print(i,end="  ")
        i=i+1
    return 
factors(12)


# ## factors of a given number

# In[14]:


list1=[1,2,3,4,5]
print(list1)
print(list1[0])


# ## Lists

# In[16]:


list2=["a","b","c"]
for x in list2:
    print(x,end="  ")


# ## for loop

# In[30]:


list1=[1,2,3,4,5,6,7,8]
for x in list1:
    print(x,end=" ")
print()
print(list1[4])
print(list1[0:7])
print(list1[:7])


# In[48]:


list1=[1,2,3,4,5,6,7,8]
for x in list1:
    print(x,end="  ")
print()
print(list1[1:-1])##emits the first and the last number
print(list1[2:-2])##emits the first and the last two numbers
print(list1[::2])##alternate
print(list1[::3])
print(list1[::-2])##alternate numbers from the end
print(list1[-1])
print(list1[-2])


# ## slice operators

# In[59]:


list1=[1,2,3,4,5,6,7,8]
list2=['a',"b","c"]
print(list1)
list1[5]=70
print(list1)
del list1[2]##delete
print(list1)
print(list2)
print(list1+list2)


# In[63]:


list1=[1,2,3,4,5,6,7,8]
print(list1)
print(len(list1))
list1.append(15)
print(list1)
print(len(list1))
list1.append(8)
list1.append(8)
print(list1)
print(list1.count(8))


# In[76]:


list1=[1,7,2,3,4,5,6,7,8,7]
print(list1.index(3))
list1.insert(2,2019)
print(list1)
list1.remove(7)
print(list1)
list1.remove(7)
print(list1)
list1.reverse()
print(list1)


# In[ ]:




