Computer Science
Record what happens when the following statements are executed:
(a) print (n=17)
(b) print (8 + 9)
(c) print (4.2, "hello", 6 - 2, "world", 15/2.0)
(d) print ("123abc", sep = '-')
(e) print ("XXX", end ='!')
Getting Started
2 Likes
Answer
(a) print(n=17) — It raises an error because the syntax print(n=17) is incorrect. In this context, n=17 is trying to use an argument name assignment within the print() function, which is not valid.
(b) print(8 + 9) — 17
(c) print(4.2, "hello", 6 - 2, "world", 15/2.0) — 4.2 hello 4 world 7.5
(d) print("123abc", sep = '-') — 123abc
(e) print("XXX", end ='!') — XXX!
Answered By
2 Likes
Related Questions
Write the given instructions in Interactive and Script modes to get the following result:
Python is easy to learn and write. It allows us to work in two modes: Interactive mode and Script mode. Interactive mode is also known as Python Shell and Script mode is known as Python Editor. It is a platform-independent language. We find it interesting to work with Python.Write a code that prints your full name and your birthday as separate strings.
Use IDLE to calculate:
(a) 6+4*10
(b) (6+4) *10
Try the following code on Python Shell and evaluate the output generated:
>>> print("Python is easy to learn and write.") >>> print(3.14159*7) >>> print('I am a class XI' + 'student') >>> print('I', 'm') >>> print("class XI student") >>> print("I'm", 16, "years old")