Ash is now an expert in python function topic. So, he decides to teach others what he knows by making a question on it. Problem statement of his question is as follows.
Your task is to write a function outer_layer(num) that returns function inner_layer, where num is a positive integer. Function inner_layer(div) check whether num is divisible by div or not, its return type is bool (True/ False).
num is of type string
div is of type int and belongs to {2, 5, 9, 10}
Functions are Objects - Since functions are just like variables, they can be returned from a function!
def outer_layer():
print 'This is outer layer'
def inner_layer():
print 'This is inner layer'
return inner_layer
def __name__ == '__main__':
func_obj = outer_layer() # func_obj now becomes inner_layer, and This is outer layer is printed on the screen.
func_obj()Output:
This is outer layer
This is inner layerWrite a program in C to find out the frequency of elements in an array
Write a c++ program using string function that will accept the course
abbreviation as input value and it will display the corresponding
college.
def countdown(n):
if n <= 0:
print('Blastoff!')
else:
print(n)
countdown(n-1)
Write a new recursive function countup that expects a negative argument and counts “up” from that number. Output from running the function should look something like this:
>>> countup(-3)
-3
-2
-1
Blastoff!
Write a Python program that gets a number using keyboard input. (Remember to use input for Python 3 but raw_input for Python 2.)
If the number is positive, the program should call countdown. If the number is negative, the program should call countup. Choose for yourself which function to call (countdown or countup) for input of zero.
Provide the following.
Create a program that asks the user to input 5 numbers. The numbers should be stored in a list, after which, your program should determine the lowest number on the list using a loop then it will display the lowest number.
Create a program to Delete and copy a file in C#.
Write a program to act as a digital combination lock safe. Create 3 buttons representing 1, 2 and 3. The user clicks on the buttons trying to guess the correct numbers eg (3321). Use a label to keep track of and display code enrered so far. Only once the correct numbers are pressed, the program congratulates the user with a message.
#include <iostream>
#include <vector>
std::vector<std::string> getUniqueBrands(const std::vector<std::string>& brand1, const std::vector<std::string>& brand2)
{
throw std::logic_error("yet to be implemented");
}
int main()
{
std::vector<std::string> brand1 = {"LOUIS_VUITTON", "HERMES", "PRADA");
std::vector<std::string> brand2 = {"GUCCI", "PRADA", "HERMES");
std::vector<std::string> result = getUniqueBrands(brand1 , brand2);
for(auto element : result)
{
std::count << element<< ' ';
//should print GUCHHI HERMES LOUIS_VUITTON PRADA
}
}
Write a C++ program that asks the user to enter 10 integer values in an array. After entering 10
elements find the maximum number and display it on output screen.
Create a program the user will input 5 grades (choose any subjects and input any grades). Determine individual subjects either passed or failed. Lastly, calculate the average grade and determine whether if passed or failed.
Sample output:
Student Name: Jessica
Math: 74 - Failed
Science: 89 - Passed
English: 74 - Failed
*If the average grade is >= 75
the output should be
PASSED!
*If the subject grade is below 74 the output should be
You need to re-take in Math Subject and English Grade
*If the average grade is <= 74 the output should be
YOU FAILED!