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

Write a function called recommend(temp, forecast) that prints out a recommendation about what to wear and bring based on the weather. temp is an integer number that represents the temperature in degrees. forecast is a string which describes the weather forecast for the day.

When the temperature is under 72 degrees, a jacket should be worn.

If the forecast is “showers”, “rain”, or “snow”, an umbrella should be brought.

Your output should be one of these sentences based on the forecast & temperature.

Based on the weather forecast, you should bring a jacket and an umbrella
Based on the weather forecast, you should bring an umbrella
Based on the weather forecast, you should bring a jacket
Weather is great! Have a nice day!




def winnerRPS(me, you):

  if(me == you):

    return(0)

  if(me == "rock"):

    if(you == "scissor"):

      return(1)

    else:

      return(-1)

  if(me == "paper"):

    if(you == "rock"):

      return (1)

    else:

      return(-1)

  if(me == "scissor"):

    if(you == "paper"):

      return(1)

    else:

      return(-1)

  

   

def main():

  print(winnerRPS("rock", "paper"))

  print(winnerRPS("rock", "rock"))

  print(winnerRPS("paper", "scissor"))

  print(winnerRPS( "scissor", "paper" ) # now add your own to test it more...


if __name__ == "__main__":

  main()


Can't figure out what should go in : if __name__ == "__main__":

  main()



Sum of Non-Primes




Write a program to print the sum of non-primes in the given N numbers. The numbers which are not primes are considered as non-primes.Input






The first line of input will contain a positive integer (N).




The following N lines will contain an integer in each line.Output






The output should be the sum of non-primes in the given numbers.Explanation






For example, if the given number is 5, then read the inputs in the next 5 lines and print the sum of non-primes in the given five numbers. If the given input integers in the next five lines are 8, 11, 96, 49, and 25 the output should be 178.





5. Find the total number of elements present in the below set: S={1,2,3,4,4,4,5,6}


Find the total number of elements present in the below set: S={1,2,3,4,5,6}


4. Create two tuples named numeric_tuple consisting of only integer values 10,20,30,40,50 and my_tuple which will have 30,60,50,’tup’ values

a. Find the minimum value from the numeric_tuple.

b. Concatenate my_tuple with numeric_tuple and store the result in r1.

c. Duplicate the tuple named my_tuple 2 times and store that in ‘newdupli’.


5. Find the total number of elements present in the below set:

 

6. Create an array with whole numbers values from 0 to 10 and find what is the command to extract the elements in the following sequence - 

array ([7,4,1])


7. Create a NumPy array having user input values and convert the integer type to the float type of the elements of the array. For instance:

Original array [1, 2, 3, 4] 

Array converted to a float type: [ 1. 2. 3. 4.]




  • In math notation, leading zeros are OK, as in 02. What happens if you try this in Python and why?

If you are trying to print a string, what happens if you leave out one of the quotation marks or both and why?




You can use a minus sign to make a negative number like -2. What happens for each of the following and why?




>>> 2++2





>>> 2--2





>>> 2+-2





>>> 2-+2





In math notation, leading zeros are OK, as in 02. What happens if you try this in Python and why?




What happens if you have two values with no operator and a space in between them and why?

Write a Python program that asks the user to enter an integer (X), then:


Determines if X is prime or not

If X is not prime, compute and print the factors of that integer X

Evaluate and print the equation Y=8X²+ 1, for X values from -5 to 5 using the range function and for loop


Square to the Next Level


by CodeChum Admin



We've already tried printing out the values of an array in reversed order, right? Today, we shall compute for the squares of all the numbers.





There's already a predefined array/list containing 100 integer values. Loop through each values, compute their squares, and display them.



Output



Multiple lines containing an integer.



4


9


25


10000


49


9


25


9


1


16


.


.


.