• Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Have any question?

(+91) 98222 16647
info@simplycoding.in
RegisterLogin
Simply Coding
  • Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Python

CBSE Python Question Bank on if else

  • Categories Python, Python if-else, Python
Python Question Bank on if else

CBSE Python Question Bank – ( 2 Marks Problems on if else):

1)What is the output of following code ?          
if(4+5==10):
    print("True")
else:
    print("False")
print("True")
Ans. False
          True  
 
2)What is the output of the following code
if a=1 and a =4
if(a==0):
    print("zero")
if(a==1):
    print("one")
else :
   print("a > 1")
Ans.
if a =1 >>> one
if a=4 >>> a  > 1
 
3)Under  what conditions will this code fragment print ”water”
if temp < 32:
    print("ice:")
elif temp < 212:
        print("water")
else:
        print("steam")
Ans. if temp greater than 32 and less than 212 it will print water           
 
4)What is the output produced by the following code?
x=1
if x>3 :
    if x>4:
        print("a", end='')
    else:
        print('b',end=' ')
elif x < 2:
    if(x != 0):
        print("c", end=' ')
print("d")
Ans.  c d                              
 
5)What is the error in following code ? Correct the code?
weather='raining'
if weather = "sunny":
    print("wear sunblock")
elif weather="snow":
    print("going skiing")
else:
    print(weather)
Ans.
weather='raining'
if weather == "sunny":
    print("wear sunblock")
elif weather=="snow":
    print("going skiing")
else:
    print(weather)
 
>>>raining 
 
6)What is the error in following code ? Correct the code?
n=2
if n == 0
    print("zero")
elif : n==1
    print("one")
elif n==2:
    print("two")
else   n==3:
    print("three")
Ans.
n=2
if n == 0:
    print("zero")
elif  n==1:
    print("one")
elif n==2:
    print("two")
else:
    print("three")
 
7)Which are two types of else clauses in Python, define them?
Ans.
The two types of python else clauses are:     
else in an if statement- the else clause of an if statement is executed when the condition of the if statement results into false
else in a loop statement- The else clause of a loop is executed when the loop is terminating normally. i.e. when its test- condition has gone false for a while loop or when the for loop has executed for the last value in sequence  

 

8)Write a program to check if the number is buzz nos or not (BUZZ nos are numbers which are divisible by 7 or end with 7)
Ans.   
n=int(input("Enter a number:"))
if(n % 7 == 0 or n % 10 == 7):
    print (("It’s a BUZZ no"))
else:
     print ("Not a BUZZ no") 
 
9)Write a program to check if the character is a vowel or not?
Ans. 
ch=input("Enter a character:")
if ch in "aeiouAEIOU":
    print("It’s a vowel")
else:
     print ("Not a vowel") 
 
10)Predict the output of the program.
a = 10
if 5 < a < 15 :
          print (a / 2)
else:
         print (a / 5) 
Ans .    >>>5.0

  • Share:
author avatar
Simply Coding

Previous post

Python Pyplot Example
April 24, 2020

Next post

CBSE Python Questions on Operators
April 24, 2020

You may also like

for & while
Learn Python for & while
19 June, 2021
Python if elif else Notes
Learn Python if elif else
15 June, 2021
List
Python List
15 June, 2021

Leave A Reply Cancel reply

You must be logged in to post a comment.

Categories

  • Uncategorized
  • Programs
    • Python
    • Java
  • Problems
    • Python
    • Java
    • Web Development
      • Internet
    • Emerging Technologies
  • Notes
    • General
    • QBasic
    • MS Access
    • Web Development
      • XML
      • HTML
      • JavaScript
      • Internet
    • Database
    • Logo Programming
    • Scratch
    • Emerging Trends
      • Artificial Intelligence
      • Internet of Things
      • Cloud Computing
      • Machine Learning
    • Computer Fundamentals
      • Computer Networks
      • E-Services
      • Computer Hardware
    • Python
    • Java
  • School
    • ICSE
      • Computers Class 9
        • Java Introduction
        • Tokens & Data Types
        • Java Operators
        • Math Library
        • if & switch
        • For & While
        • Nested loops
      • Computer Class 10
        • Sample Papers
        • OOPS concepts
        • Functions in Java
        • Constructors
        • Arrays in Java
        • Strings in Java
    • SSC
      • IT Class 11
        • IT Basics
        • DBMS
        • Web Designing
        • Cyber Laws
      • IT Class 12
        • Web Designing
        • SEO
        • Advanced JavaScript
        • Emerging Tech
        • Server Side Scripting
        • E-Com & E-Gov
      • Computer Science 11
      • Computer Science 12
    • CBSE
      • Computer 9
        • Basics of IT
        • Cyber Safety
        • Scratch
        • Python
      • Computer 10
        • Sample Papers
        • Networking
        • HTML
        • Cyber Ethics
        • Scratch
        • Python
      • Computer Science 11
        • Computer Systems
        • Python 11
          • Python Basics
          • Python Tokens
          • Python Operators
          • Python if-else
          • Python loops
          • Python Strings
          • Python List
          • Python Tuple
          • Python Dictionary
          • Python Modules
        • Data Management
      • Computer Science 12
        • Sample Papers
        • Python 12
          • Python Functions
          • Python File Handling
          • Python Libraries
          • Python Recursion
          • Data Structures
        • Computer Networks
        • Data Management
    • ISC
      • Computer Science 11
        • Introduction to Java
        • Values & Data Types
        • Operators
        • if & switch
        • Iterative Statements
        • Functions
        • Arrays
        • String
        • Data Structures
        • Cyber Ethics
      • Computer Science 12
        • Sample Papers
        • Boolean Algebra
        • OOPS
        • Wrapper Classes
        • Functions
        • Arrays
        • String

Categories

  • Uncategorized
  • Programs
    • Python
    • Java
  • Problems
    • Python
    • Java
    • Web Development
      • Internet
    • Emerging Technologies
  • Notes
    • General
    • QBasic
    • MS Access
    • Web Development
      • XML
      • HTML
      • JavaScript
      • Internet
    • Database
    • Logo Programming
    • Scratch
    • Emerging Trends
      • Artificial Intelligence
      • Internet of Things
      • Cloud Computing
      • Machine Learning
    • Computer Fundamentals
      • Computer Networks
      • E-Services
      • Computer Hardware
    • Python
    • Java
  • School
    • ICSE
      • Computers Class 9
        • Java Introduction
        • Tokens & Data Types
        • Java Operators
        • Math Library
        • if & switch
        • For & While
        • Nested loops
      • Computer Class 10
        • Sample Papers
        • OOPS concepts
        • Functions in Java
        • Constructors
        • Arrays in Java
        • Strings in Java
    • SSC
      • IT Class 11
        • IT Basics
        • DBMS
        • Web Designing
        • Cyber Laws
      • IT Class 12
        • Web Designing
        • SEO
        • Advanced JavaScript
        • Emerging Tech
        • Server Side Scripting
        • E-Com & E-Gov
      • Computer Science 11
      • Computer Science 12
    • CBSE
      • Computer 9
        • Basics of IT
        • Cyber Safety
        • Scratch
        • Python
      • Computer 10
        • Sample Papers
        • Networking
        • HTML
        • Cyber Ethics
        • Scratch
        • Python
      • Computer Science 11
        • Computer Systems
        • Python 11
          • Python Basics
          • Python Tokens
          • Python Operators
          • Python if-else
          • Python loops
          • Python Strings
          • Python List
          • Python Tuple
          • Python Dictionary
          • Python Modules
        • Data Management
      • Computer Science 12
        • Sample Papers
        • Python 12
          • Python Functions
          • Python File Handling
          • Python Libraries
          • Python Recursion
          • Data Structures
        • Computer Networks
        • Data Management
    • ISC
      • Computer Science 11
        • Introduction to Java
        • Values & Data Types
        • Operators
        • if & switch
        • Iterative Statements
        • Functions
        • Arrays
        • String
        • Data Structures
        • Cyber Ethics
      • Computer Science 12
        • Sample Papers
        • Boolean Algebra
        • OOPS
        • Wrapper Classes
        • Functions
        • Arrays
        • String
Simply Coding Computer Courses for School                Privacy Policy     Terms of Use     Contact Us

© 2021 Simply Coding

Login with your site account

Lost your password?

Not a member yet? Register now

Register a new account

Are you a member? Login now