Advertisement
naren_paste

assign_01

Oct 6th, 2023
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | Source Code | 0 0
  1. # Question: 04
  2.  
  3. my_list = [42, "Hello, GPT-3.5!", 3.14, True, ['a', 'b', 'c'], {"key": "value"}, None, (1, 2, 3), 7.5, False]
  4.  
  5. for element in my_list:
  6.     print(f"Element: {element}, Data Type: {type(element)}")
  7.  
  8.  
  9. # Question: 05
  10.  
  11. # Taking input for numbers A and B
  12. A = int(input("Enter the dividend (A): "))
  13. B = int(input("Enter the divisor (B): "))
  14.  
  15. # Initializing a variable to count the number of divisions
  16. count = 0
  17.  
  18. # Checking if B is not zero to avoid division by zero error
  19. if B != 0:
  20.     while A % B == 0:
  21.         # Dividing A by B and updating the value of A
  22.         A = A / B
  23.         # Incrementing the count of divisions
  24.         count += 1
  25.  
  26.     print(f"{A} is not divisible by {B}.")
  27.     print(f"{count} times {B} divides {A} evenly.")
  28. else:
  29.     print("Error: Cannot divide by zero. Please enter a non-zero divisor.")
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement