Tuesday 10 September 2024

Operator precedence and associativity Practice questions in python

 What will be the output of following statement?

1.     22 % 3

2.     47%6

3.     -47%6

4.     47%-6

5.     -47%6

6.     2+3-1*2*3*2

7.     3*1**3

8.     2+9*((3*12)-8)/10

9.     4//2*3+5/2+1

10.  43.55+2/2

11.  4.00/(2.0+2.0)

12.  (2-6+3**2*3)+7

13.  24//6%3

14.  24//4//2

15.  x>>2=2

16.  x<<2

17.  4^12

18.  not(3>4)

19.  not(1&1)

20.  13.25+4/2

21.  3+3.00

22.  3**3.0

23.  343%15

24.  14 + 14%15//4

25.  5*10+11/2

26.  8*2+4**2//5-3

27.  1+(2-3)*4**5//6

28.  5%3+4**2

29.  6+5/4**2//5+8

30.  16*5/4*2/5-8

31.  6/3 + 4**3//8-4

32.  4+3*5/3-5%2

33.  5+3**2/2

34.  3-2**2**3+99/11

35.  15.0/4+(8+3.0)

36.  10 * (3 + 5) // 2

37.  8 / 2 + 2 * 3

38.  5 + 2 * 3 ** 2

39.  8 % 3 + 2 ** 2 * (2 + 2)

40.  (3 + 2) * 4 / 2 ** 2

41.  7<4 or 6>3 and not 10 ==10 or 17>4

42.  5<10 and 12>7 or not 7>4

43.  not(True) and False

44.  True or False

45.  not(False and True)

46.  True and not(False)

47.  4 < 5 and 5 < 6

48.  3 != 3 or 5 > 4

49.  10 == 10 and 5 > 6

50.  (5 != 5) or (6 >= 6)

51.  (6 > 5) or (7 <= 7)

52.  10 > 5 < 2

53.  3 * "Hello"

No comments:

Post a Comment