Advertisement
Guest User

Victor Sterpu Homework

a guest
Jan 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. # Question 1&2
  2. print('Insert low boundary')
  3. down=int(input())    # the lower limit of range
  4. print('Insert up boundary')
  5. up=int(input())      # the upper limit of range
  6. print('Insert first divisor')
  7. number1=int(input())  # the first divisor
  8. print('Insert second divisor')
  9. number2=int(input())  # the second divisor
  10. count=0               # nr of solutions
  11. summ=0                # sum of the solutions
  12. for i in range(down,up+1):
  13.    if i%number1==0 and i%number2!=0:
  14.          count+=1
  15.          summ+=i
  16. print('Number of solutions=',count)
  17. print('Sum of solutions=',summ)
  18.  
  19. # Question 3&4
  20. import numpy as np
  21. a=np.arange(24)   # First vector
  22. b=np.arange(24)   # Second vector
  23. print('Insert nth element')
  24. position= int(input())
  25. dotproduct=np.dot(a,b)
  26. finarray=a*b      # Element wise product
  27. element=np.array(finarray)
  28. print('dotproduct=',dotproduct)
  29. print(position,'th element=',element[position-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement