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

from karel.stanfordkarel import *


"""

Your job in the assignment is to add the necessary code to

instruct Karel to walk to the door of its house, pick up the

newspaper (represented by a beeper, of course), and then return

to its initial position in the upper left corner of the house.

"""


def main():

  """

  You should write your code to make Karel do its task in

  this function. Make sure to delete the 'pass' line before

  starting to write your own code. You should also delete this

  comment and replace it with a better, more descriptive one.

  """

  pass


# There is no need to edit code beyond this point


if __name__ == "__main__":

  run_karel_program()


from karel.stanfordkarel import *


"""

Your job in the assignment is to add the necessary code to

instruct Karel to put beeper at the four corner of the room

and return to its original position at bottom left.

"""


def main():

  """

  You should write your code to make Karel do its task in

  this function. Make sure to delete the 'pass' line before

  starting to write your own code. You should also delete this

  comment and replace it with a better, more descriptive one.

  """

  pass


# There is no need to edit code beyond this point


if __name__ == "__main__":

  run_karel_program()


A Pythagorean Triplets is a set of three integers a, b, c such that a2+b2=C2. In the given limit L. Find the number of Pythagorean Triplets R that can be formed (such that a<b<c).

Area and Perimeter of square


you are given a side of square as input.Write a program to find the perimeter and area of square.


input

the input is an integer representing the length of the side of the square


output

the first line of the output should contain area of the square, and the second line of the output should contain the perimeter of the square as per the format shown in the sample output.


explanation

given the length of the side is 2 .

as the area of square is side*side and perimeter of the square is 4*side


the output should be


area of the square is : 4

perimeter of the square is : 8


sample input 1

3


sample output 1

area of the square is : 9

perimeter of the square is : 12


sample input 2

4


sample output 2

area of the square is : 16

perimeter of the square is : 16


Elements in the range


You are given three numbers. Check if any of the numbers exist in the range from 10 to 20(including 10 to 20).


input

the first,second and third lines of inputs are the integers.


output

the output should be either True or False


Explanation

Given a = 2,b = 4,c = 16 , 16 is in the range between 10 and 20.

so the output should be True.


sample input 1

2

4

16


sample output 1

True


sample input 2

2

4

6


sample output 2

False


String repetition-4


you are a given string.repeat the same string N times separated by space.


explanation

in the given example the string is messages , N = 3 .

so we have to repeat the string three times.then we get messages messages messages

as output


sample input 1

messages

3


sample output 1

messages messages messages


sample input 2

pop

4


sample output 2

pop pop pop pop


compare last three characters


write a program to check if the last three characters in the given two strings are same.


input

the first and second lines of inputs are the same.


output

the output should be either True or False


Explanation

given strings are apple , pimple. in both strings,the last three characters ple are common.


sample input 1

apple

pimple


sample output 1

True


sample input 2

meals

deal


sample output 2

False


write a program that asks the user to enter a name and then prints Howdy NAME. Your program should repeat these steps until the user inputs Sage. ["Sam", "Lisa", "Micha", "Dave", "Wyatt", "Emma", "Sage"]


There are multiple (T) bookstores in the area. Each shopkeeper has a list of B integers that represents the cost of each book. You have different pocket money(P) for each bookstore. Write a program to calculate the maximum number of books you can buy in each store with the corresponding pocket money.


Explanation

Given P = 600 and B = [120, 140, 110, 180, 120, 110] with a pocket money of 600, we can buy the books at index 0,1,2,4,5 , whose sum is 120+140+110+120+110 is equal to P.

Given P = 300 and B = [120 110 1300 130] with a pocket money of 300, we can buy the books at index 0,1 whose sum is 120 + 110 and is less than P.

Given P = 100 and B = [220 1000 500 2000] with pocket money of 100, we can't buy any book. So the output should be Retry.



Sample Input1

3

6 100

20 40 10 80 20 10

4 70

20 10 300 30

4 200

220 1000 500 2000


Sample Output1

5

3



Sample Input2

2

8 250

2070 1350 365 2750 30 20 140 240

4 500

1070 2893 2200 39


Sample Output2

3

1


Problem 2: Fill in the function shopSmart(orders,shops) in shopSmart.py, which takes an orderList (like the kind passed in to FruitShop.getPriceOfOrder) and a list of FruitShop and returns the FruitShop where your order costs the least amount in total. Don't change the file name or variable names, please. Note that we will provide the shop.py implementation as a "support" file, so you don't need to submit yours. Test Case: We will check that, with the following variable definitions: orders1 = [('apples',1.0), ('oranges',3.0)] orders2 = [('apples',3.0)] dir1 = {'apples': 2.0, 'oranges':1.0} shop1 = shop.FruitShop('shop1',dir1) dir2 = {'apples': 1.0, 'oranges': 5.0} shop2 = shop.FruitShop('shop2',dir2) shops = [shop1, shop2] The following are true: shopSmart.shopSmart(orders1, shops).getName() == 'shop1' and shopSmart.shopSmart(orders2, shops).getName() == 'shop2'


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS