In: Computer Science
I need the ex1 and ex2 files written out. The book is "in a byte of python" basics chapter. I can copy and paste WORKING CODE into an editor. Thank you!
1. In A Byte of Python
4. 10 Points |
// For any doubt, feel free to comment.
// I am providing both codes and screenshots
ex1.py
#adding identifying comments for future use
#Copying code from "Example: Using Variables And Literal Constants"
#below code running without errors
i = 5
print i
i = i + 1
print i
s = '''This is a multi-line string.
This is the second line.'''
print s
ex2.py
# 5.1 - Comments
#adding identifying comments for future use
''' Adding multi-lines
comments'''
#adding single line comments
# 5.2 - Literal Constants
s = 'This is a literal constant'
print s
# 5.3 - Numbers
n = 100 #Numbers
print n
# 5.4 - Strings
s1 = 'String in single quotes'
s2 = "String in double quotes"
s3 = '''String in triple quotes'''
print s1
print s2
print s3
# 5.5 - Variable
v = 'I am a variable = 100'
print '{0} printing with format '.format(v)
# 5.4.6 - Escape Sequences
s4 = 'This is the first line\nThis is the second line'
print s4