Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Simran Modi (ID: 29602610)
- # created: 24/oct
- #
- # Task:
- # Read a list of integers from user input.
- # Find all pairs of numbers in the list whose product is even and whose sum is odd.
- # Print out a formatted list of the pairs.
- # receiving input
- num = input("Input numbers with a single space in between and press enter when done: ")
- num = num.strip("\n").split(" ")
- num = [int(x) for x in num]
- # calculating which pairs are valid
- output_lst = []
- for num1 in num:
- for num2 in num:
- if (num1*num2)//2 % 0 and (num1+num2)//2 % 1:
- output_lst.append((num1,num2))
- # printing output
- for i in range(len(output_lst)):
- print("Pair {}: {},{}".format(i+1,output_lst[i][0],output_lst[i][1]))
- # end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement