Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Number of moves:


you are given a nxn square chessboard with one bishop and k number of obstacles placed on it. A bishop can go to different places in a single move. find the total no.of places that are possible for the bishop in a single move. Each square is referenced by a type describing the row, R, and column, C, where the square is located.


explanation: given N=6 K=2


bishop position 5 2


obstacle positions (2 2), (1 5)


the bishop can move in so o/p is 6


I/p:


6 2


5 2


2 2


1 6


O/p:


6


I/p:


6 4


3 3


1 3


3 1


5 1


1 5


O/p: 7


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 layer






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.

  • The code of your program.
  • Output for the following input: a positive number, a negative number, and zero.
  • An explanation of your choice for what to call for input of zero.

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.

Variables, python operators,data types,string slicing, range of string using list, python conditional statements,user input, looping statement s, python function s, exception handling, file handling, module concept write a code using all these things in python


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!

Write a function in this file called nine_lines that uses the function three_lines (provided below) to print a total of nine lines.

Now add a function named clear_screen that uses a combination of the functions nine_lines, three_lines, and new_line (provided below) to print a total of twenty-five lines. The last line of your program should call first nine_lines and then the clear_screen function.

The function three_lines and new_line are defined below so that you can see nested function calls. Also, to make counting “blank” lines visually easier, the print command inside new_line will print a dot at the beginning of the line


1. Identify and analyse your audience in the scenario stated above. 2. Provide an appropriate e-mail invitation to your trainees inviting them to a virtual training on a given date and time. You may use any conference platform of your choice. 3. Design a workflow diagram to show the company's website review process. 4. Produce a concise technical report for the Director of ICT regarding the company website review project. 5. Produce a memo to submit the technical report in (4) above.


Write a function in this file called nine_lines that uses the function three_lines (provided below) to print a total of nine lines.

Now add a function named clear_screen that uses a combination of the functions nine_lines, three_lines, and new_line (provided below) to print a total of twenty-five lines. The last line of your program should call first nine_lines and then the clear_screen function.

The function three_lines and new_line are defined below so that you can see nested function calls. Also, to make counting “blank” lines visually easier, the print command inside new_line will print a dot at the


Example 1: Define a function that takes an argument. Call the function. Identify what code is the argument and what code is the parameter.


Example 2: Call your function from Example 1 three times with different kinds of arguments: a value, a variable, and an expression. Identify which kind of argument is which. 


Example 3: Create a function with a local variable. Show what happens when you try to use that variable outside the function. Explain the results.


Example 4: Create a function that takes an argument. Give the function parameter a unique name. Show what happens when you try to use that parameter name outside the function. Explain the results.


Example 5: Show what happens when a variable defined outside a function has the same name as a local variable inside a function. Explain what happens to the value of each variable as the program runs.

184 words

PermalinkReply

4










LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS