Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Question 1&2
- print('Insert low boundary')
- down=int(input()) # the lower limit of range
- print('Insert up boundary')
- up=int(input()) # the upper limit of range
- print('Insert first divisor')
- number1=int(input()) # the first divisor
- print('Insert second divisor')
- number2=int(input()) # the second divisor
- count=0 # nr of solutions
- summ=0 # sum of the solutions
- for i in range(down,up+1):
- if i%number1==0 and i%number2!=0:
- count+=1
- summ+=i
- print('Number of solutions=',count)
- print('Sum of solutions=',summ)
- # Question 3&4
- import numpy as np
- a=np.arange(24) # First vector
- b=np.arange(24) # Second vector
- print('Insert nth element')
- position= int(input())
- dotproduct=np.dot(a,b)
- finarray=a*b # Element wise product
- element=np.array(finarray)
- print('dotproduct=',dotproduct)
- print(position,'th element=',element[position-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement