HomeComputer SciencePracticalClass 12Non Zero Double Odd Values

Class 12 Programs

Quick Tips

  • • Import random module for number generation
  • • Use randint(1, 6) for dice simulation
  • • Handle user input validation properly

Non Zero Double Odd Values

AIM

To write a Python program to find non-zero double odd values.

ALGORITHM

  1. Start
  2. Input a list of numbers
  3. Filter out non-zero numbers
  4. Check if the numbers are odd
  5. Display the non-zero double odd values
  6. Stop

PROGRAM

# Python program to find non-zero double odd values

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
non_zero_double_odd_values = [num for num in numbers if num != 0 and num % 2 != 0]

print("Non-zero double odd values:", non_zero_double_odd_values)

OUTPUT

Non-zero double odd values: [1, 3, 5, 7, 9]

CONCLUSION

Thus, the given program was successfully executed and the output was verified as per the expected result.

VIVA QUESTIONS

  1. What are arithmetic operators in Python?

    Arithmetic operators are symbols used to perform mathematical operations: +, -, *, /, %, //, and **.

  2. What is list comprehension?

    List comprehension is a concise way to create a new list by filtering or modifying an existing list in Python.