Mathematical functions, strings and objects Flashcards
What is ASCII?
ASCII (American Standard Code for Information Interchange) is an 8-bit encoding scheme for representing all uppercase and lowercase letters, digits, punctuation marks, and control characters. ASCII uses numbers 0 through 127 to represent characters.
ASCII (American Standard Code for Information Interchange), an 8-bit _____ ______ for representing all _____ and ______ letters, _____, _______ ______, and ______ ______. ASCII uses numbers ____ through _____ to represent characters.
ASCII (American Standard Code for Information Interchange), an 8-bit encoding scheme for representing all uppercase and lowercase letters, digits, punctuation marks, and control characters. ASCII uses numbers 0 through 127 to represent characters.
Unicode is…
…an encoding scheme for representing international characters
What will be displayed by print(ord('z') - ord('a'))? A. 25 B. 26 C. a D. z
A. 25
Suppose x is a char variable with a value 'b'. What will be displayed by the statement print(chr(ord(x) + 1))? A. a B. b C. c D. d
C. c
An escape sequence is a special notation that consists of a ________ followed by a _______ or a combination of ______.
An escape sequence is a special notation that consists of a backslash () followed by a character or a combination of digits.
The backslash \ is called an ______ _______
escape character
How do you display the characters \ and “?
print(“\”)
print(“"”)
Which of the following statement prints smith\exam1\test.txt? A. print("smith\exam1\test.txt") B. print("smith\\exam1\\test.txt") C. print("smith\"exam1\"test.txt") D. print("smith"\exam1"\test.txt")
B. print(“smith\exam1\test.txt”)
What will be displayed by the following code?
print(“A”, end = ‘ ‘)
print(“B”, end = ‘ ‘)
print(“C”, end = ‘ ‘)
print(“D”, end = ‘ ‘)
A. ABCD
B. A, B, C, D
C. A B C D
D. A, B, C, D will be displayed on four lines
C. A B C D
Suppose i is an int type variable. Which of the following statements display the character whose Unicode is stored in variable i? A. print(i) B. print(str(i)) C. print(int(i)) D. print(chr(i))
D. print(chr(i))
The expression "Good " + 1 + 2 + 3 evaluates to \_\_\_\_\_\_\_\_. A. Good123 B. Good6 C. Good 123 D. Illegal expression
D. Illegal expression
Hint: In Python, the + operator cannot be used to concatenate a string with a number. The number needs to be converted to a string using the str(number) function.
Suppose you entered A and Z when running the following code. What is the output?
x = input(“Enter a character: “)
y = input(“Enter a character: “)
print(ord(y) - ord(x))
25
What is max("Programming is fun")? A. P B. r C. a blank space character D. u E. n
D. u
What is min("Programming is fun")? A. P B. r C. a blank space character D. u E. n
C. a blank space character