



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A collection of python programming exercises with verified answers, covering fundamental concepts such as inheritance, data types, string manipulation, loops, functions, and modules. It is a valuable resource for students learning python, offering practical examples and solutions to reinforce their understanding.
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Inheritance: how do we actually create subclasses in Python - correct answer ✔✔class Foo(Baz): x = 43 init(self): Baz__init__(self) self.thing = "thing" get_x(self): return self.x What are some interpreted languages - correct answer ✔✔Python, Javascript What are some compiled languages - correct answer ✔✔C, C++, Clojure, Earlang What are languages are both compiled and interpreted - correct answer ✔✔Java What languages support static typing - correct answer ✔✔C, C++, Java What languages support dynamic typing - correct answer ✔✔Python, Erlang, JavaScript, PHP How do you quit python interpreter - correct answer ✔✔CTRL-D or quit() How are python integer stored - correct answer ✔✔in a C signed long int. How are python floating point values stored - correct answer ✔✔C double
Python turn off escape characters - correct answer ✔✔Raw Strings with r"the string" How to access lass char of string in Python - correct answer ✔✔s1 = "bigdog" print s1[-1] Python slices format - correct answer ✔✔inclusive/exclusive. x[2:4] means x[2] to x[3] s1 = "bigdog" s1[2:4] s1[2:] s1[:4] s1[-2:] s1[2:-2] s1[2:2] s1[2:44] - correct answer ✔✔s1 = "bigdog" s1[2:4] # gd s1[2:] # gdog s1[:4] # bigd s1[-2:] # og s1[2:-2] # gd s1[2:2] # s1[2:44] # gdog Name 3 sequences in Python - correct answer ✔✔string, list, tuples In Python, can any variable be used with FOR loop - correct answer ✔✔No it has to be a sequence Python what are the bounds of this range function range (4, 20, 5) - correct answer ✔✔# 4 to 19, by 5's
Python are global variables visible everywhere - correct answer ✔✔visible throughout the module but not outside the module Python how do you see the interpreter records names - correct answer ✔✔dir()
Python does objects have their own variables - correct answer ✔✔So ANY changes made to a variable defined outside of the method definitions affects ALL such objects. Python what is init - correct answer ✔✔If init is present, it becomes the default constructor for an object. class Foo: x = 43 init(self): self.stuff = "stuff" get_x(self): print self. In this case, a new variable called stuff will be created and added to the object instance