Docsity

C859 Python Syntax Exam Questions with Correct Answers, Exams of Advanced Education

Toggle sidebar
bg1
C859 Python Syntax Exam Questions
with Correct Answers
var1, var2, var3 = 1, 2, 3 - Correct Answer ✔✔multiple variable assignment
12 - Correct Answer ✔✔integer
1.2 - Correct Answer ✔✔float
'twelve' - Correct Answer ✔✔string
"twelve" - Correct Answer ✔✔string
True or False - Correct Answer ✔✔Boolean value
type() - Correct Answer ✔✔determines type of an object (integer, boolean, etc)
int() - Correct Answer ✔✔converts to integer object
float() - Correct Answer ✔✔converts to float object
str() - Correct Answer ✔✔converts to string object
print() - Correct Answer ✔✔displays a message
+ - Correct Answer ✔✔addition (integer) or concatenation (string)
- - Correct Answer ✔✔subtraction
** - Correct Answer ✔✔power of
% - Correct Answer ✔✔modulus, remainder
/ - Correct Answer ✔✔division, always results in float
// - Correct Answer ✔✔division, always results in integer
= - Correct Answer ✔✔assignment operator
+= - Correct Answer ✔✔reassignment operator, adds
-= - Correct Answer ✔✔reassignment operator, subtracts
*= - Correct Answer ✔✔reassignment operator, multiples
/= - Correct Answer ✔✔reassignment operator, divides
< - Correct Answer ✔✔less than
> - Correct Answer ✔✔greater than
<= - Correct Answer ✔✔less than or equal to
>= - Correct Answer ✔✔greater than or equal to
pf3
pf4

Partial preview of the text

Download C859 Python Syntax Exam Questions with Correct Answers and more Exams Advanced Education in PDF only on Docsity!

C859 Python Syntax Exam Questions

with Correct Answers

var1, var2, var3 = 1, 2, 3 - Correct Answer ✔✔multiple variable assignment 12 - Correct Answer ✔✔integer 1.2 - Correct Answer ✔✔float 'twelve' - Correct Answer ✔✔string "twelve" - Correct Answer ✔✔string True or False - Correct Answer ✔✔Boolean value type() - Correct Answer ✔✔determines type of an object (integer, boolean, etc) int() - Correct Answer ✔✔converts to integer object float() - Correct Answer ✔✔converts to float object str() - Correct Answer ✔✔converts to string object print() - Correct Answer ✔✔displays a message

    • Correct Answer ✔✔addition (integer) or concatenation (string)
    • Correct Answer ✔✔subtraction ** - Correct Answer ✔✔power of % - Correct Answer ✔✔modulus, remainder / - Correct Answer ✔✔division, always results in float // - Correct Answer ✔✔division, always results in integer = - Correct Answer ✔✔assignment operator += - Correct Answer ✔✔reassignment operator, adds -= - Correct Answer ✔✔reassignment operator, subtracts *= - Correct Answer ✔✔reassignment operator, multiples /= - Correct Answer ✔✔reassignment operator, divides < - Correct Answer ✔✔less than > - Correct Answer ✔✔greater than <= - Correct Answer ✔✔less than or equal to >= - Correct Answer ✔✔greater than or equal to

== - Correct Answer ✔✔equal to != - Correct Answer ✔✔not equal to len() - Correct Answer ✔✔returns length title() - Correct Answer ✔✔capitalizes first letter of each word islower() - Correct Answer ✔✔determines if the string consists of lowercase characters count() - Correct Answer ✔✔totals number of times an argument is found within a predefined value format() - Correct Answer ✔✔inserts variable data in a string def - Correct Answer ✔✔keyword used to create functions def myfunction(): - Correct Answer ✔✔syntax for function declaration return - Correct Answer ✔✔defines output of a function if age < 16: - Correct Answer ✔✔creates an if statement else: - Correct Answer ✔✔else statement, used in conjunction with if statement or if/elif statement elif age >= 16 and age <= 18: - Correct Answer ✔✔elif statement, used in conjunction with if statement True and False - Correct Answer ✔✔False: and operation will always be false unless both sides are true True or False - Correct Answer ✔✔True: or operation will always be true unless both sides are false not(True and False) - Correct Answer ✔✔True: Boolean not operation will produce the inverse value. myNumbers = [1, 4.8, 7, 9.2, 3, 0] - Correct Answer ✔✔creates a list mylist[0] - Correct Answer ✔✔accesses first element from a list mylist[-1] - Correct Answer ✔✔accesses last element from a list mylist[1:3] - Correct Answer ✔✔slices list including second and third element mylist[:3] - Correct Answer ✔✔slices list beginning with first element and including through the third element. Index position 3 is not included in selection. mylist[3:] - Correct Answer ✔✔slices list beginning with fourth element and include remainder of the list 9.2 in myNumbers - Correct Answer ✔✔looks for a match and returns Boolean value 9.2 not in myNumbers - Correct Answer ✔✔ensures a match does not exist in list

import math - Correct Answer ✔✔imports math module from collections import defaultdict - Correct Answer ✔✔imports individual function from a module from csv import reader as scvreader - Correct Answer ✔✔mports individual function from a module and assigns it a new name $ pip3 install pytz - Correct Answer ✔✔install package through the command line import pytz - Correct Answer ✔✔imports a package split() - Correct Answer ✔✔string method used to break apart a string and return a list