Q. Click File --> New File... and type the following code into it:
myNumber = 10 print (myNumber + 1) # output statement 1 print (myNumber) # output statement 2 print (type (myNumber)) # type statement 1 myNumber = 5 + 2 print (myNumber, end = ()) # output statement 3 print (type (myNumber)) # type statement 2 myNumber= "Seven" print (myNumber) # output statement 4 print (type(myNumber) # type statement 3
Now save your code and run it by pressing F5 key.
Now in the following table fill details as asked as per your observations based on above code:
(a) | Output generated by four marked output statements in above code. | 1. 2. 3. 4. |
(b) | Output generated by three marked type statements in above code | 1. 2. 3. |
(c) | Why is the output of output statement 1 different from output statement 2 when we have added 1 to variable Number? | |
(d) | Why is the output of type statement 2 different from type statement 3 when we are displaying output of same variable myNumber? | |
(e) | Assign values 2, 4, 8 to variables a, b and c in single statement. | |
(f) | Swap the values of a, b, c through SINGLE STATEMENT so as they now hold values of c, a, and b respectively. | |
(g) | In a new program there is just one statement given belowprint (value)But it is giving problem upon running the program. Could you tell, why? |
Answer =
(a)
1. It will print 11
2. It will print 10
3. It will generate error because end = () that is wrong
4. It will not execute due to error found in previous line code.
(b)
1. <class 'int'>
2. It will not execute due to error found in previous line code.
3. It will not execute due to error found in previous line code.
(c)
In statement 1 there is addition of 1 in print function but value of myNumber will not change. That’s why it will produce different answer.
(d)
Because type statement 2 have integer type value while type statement 3 have string type value.
(e)
a, b, c = 2, 4, 8
(f)
a, b, c = c, a, b
(g)
Because here ‘value’ is variable that is not defined it means ‘value’(variable) have not any value.
thankyou
ReplyDeleteWelcome : )
Deletethank you very very much pathwalla
ReplyDeleteWelcome : )
Deletethank u
ReplyDeleteWelcome 😊😊
DeleteThankyouuuu so much:)
ReplyDeleteWelcome 😊😊😊
DeleteHelpful ☺️
ReplyDeleteThank you 😊
DeleteThank you, this was really helpful and saved my time. Is there any option to go on to page carrying next lesson answers ? If not by adding a next button, it would make this website a way more better to use
ReplyDeleteSorry, because every year Sumita arora pattern changes.
DeleteThank you so much :D
ReplyDeleteWelcome : )
DeleteGood job friend, it literally saved my many days and it helped a lot in doing holiday homework
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )