-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunct.py
More file actions
58 lines (40 loc) · 979 Bytes
/
funct.py
File metadata and controls
58 lines (40 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#conputing volume using function in two ways
import cmath
pi=3.142
def vol(rad):
#local variables
return(4/3.0)*pi*pow(rad,3)
print vol(3)
#or using lambda assignment
vol1=lambda rad:(4/3.0)*pi*pow(rad,3)
v=vol1(4)
print 'The lambda calculated volume is: ',v
#checking if a number is in a given range of values
def chk(num,low,high):
if num in range(low,high):
print 'number is within the range'
else:
print 'number not within the range'
chk(5,3,6)
#input a string and count numper of upper n lower case characters
#palindrome
e=raw_input('Enter a word: ')
def pali(e):
if e[:]==e[::-1]:
print 'Word is palindrome'
else:
print'Word not palindrome'
pali(e)
#panagram
#import string
#def pana(srt1,alphabet=string.ascii_lowercase):
# alphaset=set(alphabet)
# return alphaset <= set(str1.lower())
#pana('This is a normal sentence')
#multioly through a list
def multi(nums):
tot=nums[0]
for i in nums:
tot=tot*i
return tot
print multi([1,2,34,4])