Write code with selection statements that is equivalent to t

Write code with selection statements that is equivalent to the following, but does not use elif. Does the following selection statement correctly identify if the variable aNurr. has been assigned a value that is ONLY one of the following: -1, 0, 1, 2, 3, 4, or Explain your answer if (aNum > -2 or aNum

Solution

1.

print(\'Both number and letter are same\') if (num==32 and letter==\"4\") else print(\'one of number or letter are 33\') if((num==32 and letter==\"33\") or (num==33 and letter==\"4\")) else print(\'neither of number or letter are 33\')

2.

No because it is given if( anum>-2 or aNum<6) , if any one of the condition is true it will execute the statements inside the if statement . Example if aNum =-3 then aNum>-2 evaluates false but aNum<6 evaluates true so the if sttement is satisfied

The loop condition must be if( aNum>-2 and aNum<6)

3.

four written for for

range error: \'float\' object cannot be interpreted as an integer

print(\"The num is,\"x) syntax error

4.

False,the boolean expression either evaluates to true or false

5.

>>> power_val = int(input(\'Till What value you want to generate: \'))
Till What value you want to generate: 90
>>> value=0
>>> i=1
>>> while(True):
   value=pow(3,i)
   if(value<power_val):
       print(value)
   else:
       break
   i=i+1

3
9
27
81

6.

//--> floor division

**-->power

range(-452, 5//3, 3**5)

start at -452 till 5//3=1 increment by3**5=243

7.

import random

if you want to print random values using random.random() we have to import random

8.

0%2=0

 Write code with selection statements that is equivalent to the following, but does not use elif. Does the following selection statement correctly identify if t
 Write code with selection statements that is equivalent to the following, but does not use elif. Does the following selection statement correctly identify if t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site