<jupyter_start><jupyter_text>The Last String Character<jupyter_code>a1[-1]
a1.upper()
a1.lower()
a1[1:12]
len(a1)
a1.title()
#Data Structures
# 1. tuples these are immutable data structures
tup1 = (1,'a',True,'23.45')
tup1[0]
tup1[-1]
tup1[1:3]
#immutability od tuple
tup1[2]=5
#Lists are Mutable
l1=[2,3.5,True,'<NAME>']
l1[0]
l1[1:3]
l1[3] ='<NAME>'
l1
l1.append('Musungu')
l1
l1.pop()
l1
#Dictionaries Takes Key Value Pairs
dict1={"Name":"<NAME>","Age":10,"School":"Kenyatta University","Home":"Kitale","Married":False
}
dict1
dict1.keys()
dict1['Name']="<NAME>"
dict1
#Sets : 1.Do not Have duplicate items 2.Order of the elements are not reserved
s1={1,1.2,True,'<NAME>'}

s1
s1={1,1.2,True,'<NAME>','<NAME>'}
s1
s1.add("<NAME>")
s1
s1.update([2.2,False,'Mucharage'])
s1
#control flow statements
a = 10
b = 20
if b > a :
    print("b is greater than b")
if a > b :
    print("b is greater than a")
if a > b :
    print("a is greater than b")
else:
    print("b is greater than a")
a = 10
b = 20
c = 30

if (a > b) & (a > c):
   print("a is the greatest")
    
elif (b > a) & (b > c):
    print("b is the greatest")
else:
   print("c is the greatest")
tp1=("a","b",True,3.45,346,3+5j)
if True in tp1:
    print("There is a boolean in the tuple")
#if with list
l1=[20,30.45,True,"<NAME>"]
if l1[0]==20:
    print(l1[0])
#if with dictionaries
d1={"Mango":100,"Banana":456,"Oranges":45}
if d1['Mango']== 100:
    d1['Mango']=d1['Mango']+20;
    d1
d1
#while with variables
a=10
a=1
while(a<=10):
    print("Iam awsesome");
    a=a+1;
#for loop
l1=['red','green','yellow','blue']
for i in l1:
    print(i)
#nested for loops
l1=['green','yellow','blue','grey'] #assuming I want to mix each of these colours with the all the next colours
l2=['orange','magenta','black']
for i in l1:
    for j in l2:
        print(i ,"mixed with", j)
# functions
def hello():
    print('hello world')
hello() #invoking the function
def adding(x,y): #function with parameters
    return x+y;
adding(10,100)
def checkif(x):
    if(x%2 == 0):
        print(x, "is even")
    else:
        print(x, "is odd number")
checkif(4)
checkif(5)
#Object oriented Programming
class Phone:
    def makePhonecall(self):
        print("Making a Phone call")
        
    def playGame(self):
        print('playing game')
p1=Phone()
p1.makePhonecall()
p1.playGame()
#Class with prameters
class Phone:
    
    def addPhoneColor(self,color):
        self.color=color
        
    def addCost(self,cost):
        self.cost=cost
        
    def showColor(self):
        return self.color
    
    def showCost(self):
        return self.cost
        
    def makePhonecall(self):
        print("Making a Phone call")
        
    def playGame(self):
        print('playing game')
p2=Phone()
p2.addPhoneColor("Green")
p2.addCost(450)
p2.showCost()
p2.showColor()
#inheritance in python
class Iphone(Phone):
    def cureCancer(self):
        print("I can Cure Cancer")
p3=Iphone()

p3.addCost(9000)
p3.addPhoneColor("pink")
p3.showColor()
p3.showCost()
#Packages in python for Data science
#Numpy For perfoming Numerical and Scientific Functionalities<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16847133757961782, 'fraction_numerical': 0.051273885350318474, 'mean_word_length': 3.802752293577982, 'pattern_counts': {'":': 8, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '108465', 'license': 'MIT', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1228, 'n_words': 328, 'path': '.ipynb_checkpoints/python_introduction-checkpoint.ipynb', 'repo_name': 'KEVINAMAYI/data-science-introduction', 'size': '3193'}