Advertisements
Advertisements
Following is an algorithm to classify numbers as “Single Digit”, “Double Digit” or “Big”.
Classify_Numbers_Algo
INPUT Number
IF Number < 9
"Single Digit"
Else If Number < 99
"Double Digit"
Else
"Big"
Verify for (5, 9, 47, 99, 100, 200) and correct the algorithm if required.
Concept: undefined >> undefined
For some calculations, we want an algorithm that accepts only positive integers up to 100.
Accept_1 to 100_Algo
INPUT Number
IF (0 <= Number) AND (Number <= 100)
ACCEPT
Else
REJECT
- On what values will this algorithm fail?
- Can you improve the algorithm?
Concept: undefined >> undefined
Advertisements
Write the corresponding Python assignment statement:
Assign 10 to variable length and 20 to variable breadth.
Concept: undefined >> undefined
Write the corresponding Python assignment statement:
Assign the average of values of the variable's length and breadth to a variable sum.
Concept: undefined >> undefined
Write the corresponding Python assignment statement:
Assign a list containing strings ‘Paper’, ‘Gel Pen’, and ‘Eraser’ to variable stationery.
Concept: undefined >> undefined
Write a program to swap two numbers using a third variable.
Concept: undefined >> undefined
Write a program to swap two numbers without using a third variable.
Concept: undefined >> undefined
Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
num1 = float(10)
print (num1)
Concept: undefined >> undefined
Observe the following program carefully, and identify the error:
mynum = 9
def add9():
mynum = mynum + 9
print mynum
add9() #function callConcept: undefined >> undefined
Using an example showing how a function in Python can return multiple values.
Concept: undefined >> undefined
Differentiate between the following with the help of an example:
Global and Local variable
Concept: undefined >> undefined
Consider the following string mySubject:
mySubject = "Computer Science"
What will be the output of the following string operation:
print(mySubject.isalpha())
Concept: undefined >> undefined
Consider the following string myAddress:
myAddress = "WZ-1, New Ganga Nagar, New Delhi"
What will be the output of the following string operation:
print(myAddress.count('New'))
Concept: undefined >> undefined
Consider the following string myAddress:
myAddress = "WZ-1, New Ganga Nagar, New Delhi"
What will be the output of the following string operation:
print(myAddress.find('New'))
Concept: undefined >> undefined
Consider the following string myAddress:
myAddress = "WZ-1, New Ganga Nagar, New Delhi"
What will be the output of the following string operation:
print(myAddress.rfind('New'))
Concept: undefined >> undefined
Consider the following string myAddress:
myAddress = "WZ-1, New Ganga Nagar, New Delhi"
What will be the output of the following string operation:
print(myAddress.split(','))
Concept: undefined >> undefined
Consider the following string myAddress:
myAddress = "WZ-1, New Ganga Nagar, New Delhi"
What will be the output of the following string operation:
print(myAddress.split(' '))
Concept: undefined >> undefined
Consider the following string myAddress:
myAddress = "WZ-1, New Ganga Nagar, New Delhi"
What will be the output of the following string operation:
print(myAddress.partition(','))
Concept: undefined >> undefined
Write a user-defined function to convert a string with more than one word into a title case string where the string is passed as a parameter. (Title case means that the first letter of each word is capitalized).
Concept: undefined >> undefined
After a fight with your friend, you did the following activities. Which of these activities is not an example of cyber bullying?
Concept: undefined >> undefined
