Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
import pandas as pd
import numpy as np
s = pd.Series(['Tom', 'William Rick', 'John', 'Alber@t', np.nan, '1234','SteveSmith'])
print s
print " "
print s.str.lower()
print " "
print s.str.upper()
print " "
print s.str.len()
print " "
print "Adding String "
print s.str.cat(sep='_')
print " "
print " "
print "Contains match "
s = pd.Series(['Tom ', ' William Rick', 'John', 'Alber@t'])
print s.str.contains(' ')
print "Replace "
print " "
print " "
print s.str.replace('@','$')
s = pd.Series(['Tom ', ' William Rick', 'John', 'Alber@t'])
print " "
print " "
print ("The number of 'm's in each string:")
print s.str.count('R')
print s.str.contains('r')
print " "
print " "
print ("Starts with:")
print s.str.startswith('J')
print ("Starts with:")
print s.str.endswith('t')
s = pd.Series(['Tom ', ' William Rick', 'John', 'Alber@t'])
print s.str.find('e')
# "-1" indicates that there no such pattern available in the element.
s = pd.Series(['Tom ', ' William Rick', 'John', 'Alber@t'])
print s.str.findall('e')
#Null list([ ]) indicates that there is no such pattern available in the element.
s = pd.Series(['Tom', 'William Rick', 'John', 'Alber@t'])
print s.str.swapcase()
print s.str.islower()
# to validate full string in lower
print s.str.isupper()
# to validate full string in upper
print s.str.isnumeric()
# to validate full string in Numeric
# Hello World program in Python
# Euler method in Python -
from __future__ import division
from math import exp
import matplotlib.pyplot as plt
import numpy as np
h=0.01
x0=0
y0=1
xmax=4
x=x0
y=y0
print "Euler method\n"
puntsEuler=[]
while x<=xmax:
puntsEuler.append((x,y))
print x,y
k1=(-2*x**3+12*x**2-20*x+8.5)
y = y + h*k1
x = x + h
#puntsEuler.append((x,y))
print x,y
print puntsEuler
print '=== Euler ===='
for i in range(len(puntsEuler)):
print puntsEuler[i][0],' --> ',puntsEuler[i][1]
print
print '============='
# dibuixant els punts i la solucio
def f(z):
return -0.5*z**4+4*z**3-10*z**2+8.5*z+1
te, eu = zip(*puntsEuler)
#tr, rk = zip(*puntsRK)
t1 = np.arange(x0, xmax, h/10)
plt.plot(te,eu,'b-',marker='o')
#plt.plot(tr,rk,'g-',marker='*')
plt.plot(t1,f(t1),'r')
plt.show()
import math # This will import math module
x = 1
y = 0
while True:
print(x)
print(math.floor(math.log10(x))+1)
y=y+(math.floor(math.log10(x))+1)
print(y)
x += 1
if y == 2007:
break
import math # This will import math module
x = 1
y = 0
while True:
print(x)
print(math.floor(math.log10(x))+1)
y=y+(math.floor(math.log10(x))+1)
print(y)
x += 1
if y == 2007:
break
class S_D:
def __init__(self, price, number):
self.price= price
self.number= number
def performance(self):
if self.number >22:
print ('Event was a hit!')
elif 14<= self.number <= 22:
print ('Event was good')
else:
print('Event was a bust :(')
###Creating first instance
Event1= S_D(15,13)
Event1.performance()