1. Largest Odd Revisited: Write a program that examines three variables x, y, and z and prints out the largest odd numbe
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
1. Largest Odd Revisited: Write a program that examines three variables x, y, and z and prints out the largest odd numbe
1. Largest Odd Revisited: Write a program that examines three variables x, y, and z and prints out the largest odd number amongst them. If none are odd, print out a message indicating this. For this code, use a 'for' or 'while loop, conditionals, and a sorting function "sort' from the NumPy package). Make sure to add some comments in your code to indicate what appropriate lines of code are doing.
X = # largest odd revisited import numpy as np : 1; y = 7; z = 1000 # L = np.array([x, y, z]) Ls = np.sort(L)[::-1] # reverse sorted np array so largest first no_odds = True J for 1 in Ls: if l%2 != 0: print(f'??') else: pass if no odds ==True: print('no odds!')