Skip to content
Pooja Bhatia Classes Hari Nagar
  • We teach following classes
    • Class 12
    • Class 11
    • Class 10
    • Class 9
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship
Pooja Bhatia Classes Hari Nagar

sa 12 cs chapter 6

6. Consider following Python function that uses recursion:

sa 12 cs chapter 6 / PythonCSIP CS IP

6. Consider following Python function that uses recursion: Read More »

7. Can you find an error or problem with the above code? Think about what happens if we evaluate check(3). What output would be produced by Python? Explain the reason(s) behind the output.

sa 12 cs chapter 6 / PythonCSIP CS IP

def check(n) : if n <= 1: return True elif n % 2 == 0 : return check(n/2) else : return check(n/1) Yes, The above function will only work when the number is a power of 2. It will result in infinite recursion when n is not a power of 2. check(3) will result in

7. Can you find an error or problem with the above code? Think about what happens if we evaluate check(3). What output would be produced by Python? Explain the reason(s) behind the output. Read More »

Post pagination
← Previous 1 … 12 13 14 … 21 Next →
  • We teach following classes
    • Class 12
    • Class 11
    • Class 10
    • Class 9
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship
  • We teach following classes
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship

Copyright © 2025 Pooja Bhatia Classes Hari Nagar | Powered by Pooja Bhatia Classes Hari Nagar.