pip is run from the command line, not the Python interpreter. It is a program that installs modules, so you can use them from Python.
2015-11-23
import math
def is_sqr(x):
return int(math.sqrt(x))*10 == math.sqrt(x)*10
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return int(math.sqrt(x))*10 == math.sqrt(x)*10
print filter(is_sqr, range(1, 101))
2015-11-23
def format_name(s):
return s.lower().capitalize()
print map(format_name, ['adam', 'LISA', 'barT'])
return s.lower().capitalize()
print map(format_name, ['adam', 'LISA', 'barT'])
2015-11-19
def format_name(s):
s = s.lower()
s=s[0].upper()+s[1:len(s)]
return s
print map(format_name, ['adam', 'LISA', 'barT'])
s = s.lower()
s=s[0].upper()+s[1:len(s)]
return s
print map(format_name, ['adam', 'LISA', 'barT'])
2015-11-17
def format_name(s):
s=s.capitalize()
print map(format_name, ['adam', 'LISA', 'barT'])
s=s.capitalize()
print map(format_name, ['adam', 'LISA', 'barT'])
2015-11-16
def cmp_ignore_case(s1, s2):
s1 = s1.lower()
s2 = s2.lower()
return cmp(s1,s2)
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
s1 = s1.lower()
s2 = s2.lower()
return cmp(s1,s2)
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
2015-11-16
import math
def is_sqr(x):
return math.sqrt(x)%1==0
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return math.sqrt(x)%1==0
print filter(is_sqr, range(1, 101))
2015-11-16
def prod(x, y):
return x*y
print reduce(prod, [2, 4, 5, 7, 12])
return x*y
print reduce(prod, [2, 4, 5, 7, 12])
2015-11-16
def format_name(s):
s = s.lower()
s = s[0].upper()+s[1:]
return s
print map(format_name, ['adam', 'LISA', 'barT'])
s = s.lower()
s = s[0].upper()+s[1:]
return s
print map(format_name, ['adam', 'LISA', 'barT'])
2015-11-16