Python Basics Assignments

Conditional Statements

  1. What are the three ways of using if statement in Python?
  2. What are relational operators? What relational operators are available in Python?
  3. What are logical operators? What logical operators are available in Python?
  4. What is pseudocode? Write the pseudocode to input two numbers from the user and find theirsum.

Looping Statements

  1. What is a loop? What are the looping constructs available in Python?
  2. Write the syntax of for loop and while loop in Python.
  3. What is the main difference between a for loop and a while loop?
  4. When does the else clause of a loop get executed? Is it compulsory to have else clause in aloop?
  5. What is the use of break and continue statements in a loop? Give a suitable example toexplain.
  6. What is an infinite loop? Give an example of (i) an infinite for loop, and (ii) an infinite whileloop.
  7. What is meant by nesting of loops? Give a suitable example to explain.