Assignment Module 5
Assignment Module 5
3. Consider a list1 [3,4,5,6,7,8]. Create a new list2 such that Add 10 to the even number
and multiply with 5 if it is odd number in the list1..
4. Write a simple user defined function that greets a person in such a way that :
i) It should accept both name of person and message you want to deliver.
ii) If no message is provided, it should greet a default message ‘How are you’
#1.A) list1=[1,5.5,(10+20j),’data science’].. Print default functions and parameters exists in list1.
# C) Read the input from keyboard and print a sequence of numbers up to that number
list1=[1,5.5,(10+20j),'data science']
print(list1)
Numbers = list(range(10))
print(num)
list1=[0,1,2,3,4,5,6,7,8,9]
list2=['zero','one','two','three','four','five','six','seven','eight','nine']
#Create a dictionary such that list2 are keys and list1 are values..
dict1 = {}
dict1['zero'] = 0
dict1['one'] = 1
dict1['two'] = 2
dict1['three'] = 3
dict1['four'] = 4
dict1['five'] = 5
dict1['six'] = 6
dict1['seven'] = 7
dict1['eight'] = 8
dict1['nine'] = 9
dict1['ten'] = 10
dict1
#3.Consider a list1 [3,4,5,6,7,8]. Create a new list2 such that Add 10 to the even number and
multiply with 5 if it is odd number in the list1..
list1 = [3,4,5,6,7,8]
list2 = []
if num%2 == 0:
list2.append(num + 10)
else:
list2.append(num*5)
list2
### Write a simple user defined function that greets a person in such a way that :
# i) It should accept both name of person and message you want to deliver.
# ii) If no message is provided, it should greet a default message ‘How are you’
def greet(name= 'How are you'):
gr = 'Hello' + name
return gr
a=greet('Kamlesh')
a=greet()
greet('Kamlesh')