Practise Mcq's For Programming..

  • Uploaded by: M Idrees
  • 0
  • 0
  • August 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Practise Mcq's For Programming.. as PDF for free.

More details

  • Words: 533
  • Pages: 3
Quiz Questions & Practice Problems

Determine and state the output of the following questions in the space provided below. In case of any error(s), give details of the error(s) . (a) x=32; y=-28 if (-x!=-y-4): print("Inside If Block"); else: print("Inside Else Block");

Output:

(b) value1='option1' value2='option2' value3='option1 ' if (value1==value2): print("Inside if block"); elif (value1>value2): print("Inside elif 1"); if (value1==value3): print("if inside elif 1") elif (value2>value1): print("Inside elif 2"); if (value1==value3): print("if inside elif 2") else: print("Inside Else Block");

(c) value_1 = -140 value_2= 50.93 value_3= 121

Output:

if x > 20 : print ('x > 20') if x < 80 : print (x < 80) elif x > 80: if x < 100: print (' x < 100' ) print("Done")

x=value_1

x=value_2 Output:

x=value_3 Output:

Output:

(d) x = 5 y = 10 z = 10 answer = input("What is the name of your organization? ") if a = "ITB": print("Correct!") print(5 == x + 0.00000000001) else print("Incorrect! It is ITB.")

# What output will be produced for user input value : ITB Output: No output due to 3 Errors 1. Variable mismatch. User input is inside variable answer instead of variable a. 2. Variable assignment is being done in if header which is not allowed. Only comparisons can be done. 3. Else statement has a missing colon

(e) a=5 b=a a=4 if(a*b+6/2/3==21): print("Yes") else: print("No")

Output:

(f) print("Welcome!!") print("A. Banker") print("B. Govt. Servant") print("C. Teacher") user_input = input("What is your occupation? ") if user_input = A: money = 1000 else if user_input = B: money = 700 else if user_input = C: money = 50 print("Great! You have earned", money, " Rs.")

# what will this program output if user is Banker by profession? Output:

(g) Create a small grade generator program that inputs exam marks for two different subjects and calculates and tests their average marks for the award of a grade. The examination marks are whole numbers between 1 and 100. Grades are awarded according to the following criteria:    

>= 80 marks => Distinction >= 60 marks => Merit >= 40 marks => Pass < 40 marks => Fail

(h) Write a program that could be used by a book store to calculate a discount, based on customer status. Customers are classified either R for Regular or S for Special. Special customers have been members of the literary club for more than one year. They automatically receive a 50-Rs. discount on all purchases. The store also holds “value days” several times a year. On value days, all customers receive the 50-Rs. discount. Special customers do not receive an additional 50 Rs. off during value days, because every day is a discount for them. Each book at the store costs 1500 Rs. (i) A library charges a fine for every book returned late. For first 5 days the fine is 50 Rs. , for 6-10 days fine is hundered rupees and above 10 days fine is 200 Rupees. If you return the book after 30 days your membership will be cancelled. Write a program to accept the number of days the member is late to return the book and display the fine or the appropriate message.

Related Documents

Mcqs
August 2019 43
Mcqs
November 2019 26
Transerlate Practise
April 2020 10
The Practise
June 2020 7

More Documents from "www.khojee.wordpress.com"