





















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















































Pseudocode READ PAN If length of PAN is not ten then print “Invalid” and exit FOR x=0 to if PAN[x] is not a character THEN PRINT ‘invalid’ BREAK; END IF END FOR FOR x=5 to 9 if PAN[x] is not a digit THEN PRINT ‘invalid’ BREAK; END IF END FOR IF PAN[9] is not a character THEN PRINT ‘invalid’ END IF PRINT ‘valid’
Test Case 1 abcde1234r Valid
Test Case 3 abcd01234r Invalid
Strings
String Operations
String Operations
Escape Sequences
Escape Sequences
Length of a String —a binary 1 and 2 (coded in octal), followed by a binary 3 (coded in hexadecimal): >>> s = '\001\002\x03' >>> s '\x01\x02\x03' >>> len(s) 3
Backslash in Strings if Python does not recognize the character after a \ as being a valid escape code, it simply keeps the backslash in the resulting string: >>> x = "C:\py\code"
>>> x 'C:\py\code' >>> len(x) 10
Check this
myfile = open('C:\new\text.dat', 'w') - Error myfile = open(r'C:\new\text.dat', 'w') Alternatively two backslashes may be used myfile = open('C:\new\text.dat', 'w') >>> path = r'C:\new\text.dat' >>> print(path) # User-friendly format C:\new text.dat >>> len(path) 15