Q. In front of the Python prompt In [ ]: in Python console, type the following statements one by one.

(a) IMPORTANT: It would be more fruitful if students first evaluate the expressions on paper before typing in Python Shell as it will strengthen their learning of concepts.


(b) Do write the reason behind the result returned by Python.

Sample:

In[] : break = 10

Caution!
Statements should be typed as given here without changing the Case of any letter. (Python is case sensitive: Uppercase and lowercase letters are treated differently.)


 
S.no Statement to be typed Result Reason
1 abc123 = 25

2 abc123

3 abc123 * 2

4 print (abc123)

5 break = 10

6 Break = 10

7 break

8 print (break)

9 print (abc123 * 2)

10 123abc = 20

11 Val1 = 12.25

12 Val1

13 print (Val1)

14 Val2 = 0.05E+2

15 Val2

16 print (Val2)

17 elif = 'abc'

18 Name = "Riyan"

19 Name

20 print (Name)

21 Name * 2

22 print (Name * 2)

23 String1 = "Text"

24 String2 = "Text \ That is spread across \ Multiple lines"

25 String3 = ‘’‘Another text that is also multiline text ’’’

26 String4 = “””Third Multiline Text “””

27 String5 = ‘’’HI There! \ Python \ Is fun! ‘’’

28 String2

29 String3

30 String4

31 String5

32 String1

33 print (String1)

34 print (String2)

35 print (String3)

36 print (String4)

37 print (String5)

38 len(String1)

39 len(String2)

40 len(String3)

41 len(String4)

42 len(String5)

43 A = None

44 A

45 print (A)

46 Chk = True

47 Chk

48 print (chk)


Answer :-


 
S.no Statement to be typed Result Reason
1 abc123 = 25 >>> Value of abc123 is 25
2 abc123 25 Value of abc123 is 25
3 abc123 * 2 50 25*2 = 50
4 print (abc123) 25 Value of abc123 is 25
5 break = 10 Error break is Keyword
6 Break = 10 >>> Value of Break is 10
7 break Error break is Keyword
8 print (break) Error break is Keyword
9 print (abc123 * 2) 50 25*2=50
10 123abc = 20 Error 123abc is wrong identifier
11 Val1 = 12.25 >>> Value of Val1 is 12.25
12 Val1 12.25 Value of Val1 is 12.25
13 print (Val1) 12.25 Value of Val1 is 12.25
14 Val2 = 0.05E+2 >>> Value of Val2 is 0.5
15 Val2 0.5 Value of Val2 is 0.5
16 print (Val2) 0.5 Value of Val2 is 0.5
17 elif = 'abc' Error elif is Keyword
18 Name = "Riyan" >>> Value of Name is Riyan
19 Name “Riyan” Value of Name is Riyan
20 print (Name) Riyan Value of Name is Riyan
21 Name * 2 “RiyanRiyan” “Riyan” * 2 = “RiyanRiyan”
22 print (Name * 2) RiyanRiyan “Riyan” * 2 = “RiyanRiyan”
23 String1 = "Text" >>> Value of String1 is Text
24 String2 = "Text \ That is spread across \ Multiple lines" >>> Value of String2 is Text \ That is spread across \ Multiple lines
25 String3 = ‘’’Another text that is also multiline text ’’’ >>> Value of String3 is Another text that is also multiline text
26 String4 = “””Third Multiline Text “”” >>> Value of String4 is ThirdMultiline Text
27 String5 = ‘’’HI There! \ Python \ Is fun! ‘’’ >>> Value of String5 is HI There! \ Python \ Is fun!
28 String2 “Text \\ That is spread across \\ Multiple lines” Value of String2 is Text \ That is spread across \ Multiple lines
29 String3 “Another text that is also multiline text” Value of String3 is Another text that is also multiline text
30 String4 “Third Multiline Text” Value of String4 is Third Multiline Text
31 String5 “HI There! \\ Python \ \Is fun!” Value of String5 is HI There! \ Python \ Is fun!
32 String1 “Text” Value of String1 is Text
33 print (String1) Text Value of String1 is Text
34 print (String2) Text \ That is spread across \ Multiple lines Value of String2 is Text \ That is spread across \ Multiple lines
35 print (String3) Another text that is also multiline text Value of String3 is Another text that is also multiline text
36 print (String4) ThirdMultiline Text Value of String4 is ThirdMultiline Text
37 print (String5) HI There! \ Python \ Is fun! Value of String5 is HI There! \ Python \ Is fun!
38 len(String1) 4 Length of String1 is 4
39 len(String2) 45 Length of String2 is 45
40 len(String3) 43 Length of String3 is 43
41 len(String4) 21 Length of String4 is 21
42 len(String5) 27 Length of String5 is 27
43 A = None >>> Value of A is None
44 A >>> Value of A is None
45 print (A) None Value of A is None
46 Chk = True >>> Value of Chk is True
47 Chk True Value of Chk is True
48 print (chk) True Value of Chk is True

11 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Where are the remaining one's ?

    ReplyDelete
  2. Bhai result or reasons kaha hai

    ReplyDelete
  3. Bhai / Behen aap jo bhi hai please question ke answer mai RESULT Or REASON bhi to daale.

    ReplyDelete
    Replies
    1. Please slide the table or open in desktop.

      Delete
  4. Thank you appreciate it . You saved the day man

    ReplyDelete
  5. thank you very much... it helped me a lot

    ReplyDelete
  6. Thankyou very much Sir/Madam.... :)

    ReplyDelete
  7. Lifesaver
    Thanks

    ReplyDelete
  8. the values of val2 is wrong as it should be 5.0
    thank you for the solutions anyways : )

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post