304 North Cardinal St.
Dorchester Center, MA 02124

# Full Speed Python Educative Quiz Answers

## Get Full Speed Python Educative Quiz Answers

Python is one of the most popular coding languages today; it’s categorized as a vital benchmark of computer science knowledge in industry interviews. This highly interactive course is an accelerated introduction to Python. It is intended for users who are already familiar with the fundamentals of programming and aims to teach the Python programming language using a practical approach. It not only covers the basic Python syntax but also teaches methods specific to Python3. With most companies already switching from Python2 to Python3, this version of Python is the future.

Before moving on to more complex and powerful tools, we’ll examine the fundamentals of the language. You can also experiment with the code provided and, therefore, gain a higher understanding of how things work. This course is perfect for anyone who works as a Python developer and wants to recognize its full potential. Happy learning!

Enroll on Educative

#### Challenge 1: Check Parity of a Number

``````def checkParity(n):
result = (n % 2) ## Update result according to the parity
return result``````

#### Challenge 2: Find Values Within a Range

``````def inRange(x, y):
return (x < 1/3 < y)``````

#### Challenge 3: String Transformation

``````def getStr(s):
s=s[:1] + s + s[1:]# Transform the string
s=s[:1] + s + s[1:]
s=s[:3] + s + s[3:]
s=s[:3] + s + s[3:]
s=s[:6] + s + s[6:]
s=s[:6] + s + s[6:]
# Update the length of string
strlen = len(s)
return [s, strlen]``````

#### Challenge 4: Find Index of a Specific Value in a String

``````def findOccurence(s):
a = s.find("b") # find first occurrence of "b" in the string
b = s.find("ccc") # find first occurence  of "ccc" in the string
return [a, b]``````

#### Challenge 5: Lowercase to Uppercase

``````def changeCase(s):
a=s.upper()    ### convert string to "AAA BBB CCC"
b=s.lower()    ### convert string to "aaa bbb ccc"
return [a, b]``````

#### Quiz 1: Basic Data Types

Q1. What is the output of the following code

`print("Hello World" + "Hello World" + "Hello World" * 2)`

• Hello WorldHello WorldHello WorldHello World
• Hello WorldHello WorldHello World
• Hello WorldHello WorldHello WorldHello WorldHello World
• Hello WorldHello WorldHello World

Q2. How can you calculate the length of a string `str` in python?

• str.length()
• len.str()
• len(str)
• str.len()

#### Challenge 6: Sublist of a List

``````def getSubList():
l = [1, 4, 9, 10, 23]
l1 = l[0:3]
l2 = l[3:]
return [l1, l2]``````

#### Challenge 7: Appending Value to the End of a List

``````def AppendtoList():
l = [1, 4, 9, 10, 23]
l.append(90)
return l``````

#### Challenge 8: Averaging Values in a List

``````def getAverage():
l1 = [1, 4, 9, 10, 23]
avg = sum(l1) / len(l1)
return avg``````

#### Challenge 9: Remove Sublist From List

``````def removeList():
l1 = [1, 4, 9, 10, 23]
l2 = [4, 9]
l1.remove(l2)
l1.remove(l2)
return l1

l1 = removeList()
print(l1)``````

#### Challenge 10: List of Squares

``````def getSquare():
l1 = [x*x for x in range(1, 11)]
return l1``````

#### Challenge 11: List of Cubes

``````def getCube():
l1 = [x*x*x for x in range(1, 21)]
return l1``````

#### Challenge 12: Lists of Even and Odd Numbers

``````def ListofEvenOdds():
l1 = []
l2 = []
l1 = [x for x in range(0,21) if (x%2==0)]
l2 = [x for x in range(0,21) if (x%2!=0)]
return[l1, l2]

print(ListofEvenOdds())``````

#### Challenge 13: Sum of Squares of Even Numbers

``````def evenSquareSum():
even = [ x * x for x in range(0,21) if x % 2 == 0]
return sum(even)``````

#### Challenge 14: Even Squares Not Divisible By Three

``````def getSquare():
l1 = [x * x for x in range(0, 21, 2) if x % 3 != 0]
return l1``````

#### Quiz 2: Lists

Q1. What should be the output of the following code?

`print([5,6,7] + [8,9,10])`

• [13,15,17]
• [5,6,7,8,9,10]

Q2. Given the list. How can you add an item “baseball” in the list?

• list.append(“baseball”)
• list.insert(“baseball”)

Q3. What is the output of the following code?

``S = [x**2 for x in range(10)]print(S)``
• [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
• [0, 2, 4, 8, 16, 32, 64, 128, 256, 512]

Q4. What is the output of the following code?

``list = [n**2 for n in range(10) if n % 2 == 0]print(list)``
• [0, 4, 8, 16, 32]
• [0, 4, 16, 36, 64]

#### Challenge 15: Greatest Common Divisor

``````import math
def findGCD(a, b): ## Alter the declaration to get the function to take two input arguments
return math.gcd(a, b)``````

#### Challenge 16: Calculate Sine, Cosine, and Tangent of User Input

``````import math
def calculateSinCosTan(x):
sine = math.sin(x)
cos = math.cos(x)
tan = math.tan(x)
return [sine, cos, tan]``````

#### Challenge 17: Compute & Return Maximum

``````def findMaximum(x,y):
max2 = max(x, y) #create a variable max2
return max2 #returns the maximum of two numbers x and y``````

#### Challenge 18: Check If a Number Is Divisible by Another

``````def isDivisble(x, y):
if  x % y == 0:
return True
else :
return False``````

#### Challenge 19: Compute nth Fibonacci Number

``````def fibonacci(n):
if n <= 1:
return n
else:
return(fibonacci(n-1) + fibonacci(n-2))``````

#### Challenge 20: Compute Sum of First ‘n’ Natural Numbers

``````def sum_N_Numbers (n):
if n <= 1:
return n
else:
return n + sum_N_Numbers (n-1)``````

#### Quiz 3: Modules and Functions

Q1. What is the output of the following function?

``def function(fruit = "Orange"):  print("I like " + fruit)function("Banana")function("Peach")function()function("Mango") ``
• Option 1
``````I like Banana
I like Peach
I like Orange
I like Mango``````
• Option 2
``````I like Banana
I like Peach
I like Peach
I like Mango``````
• Option 3
``````I like Banana
I like Peach
I like Mango
``````

Q2. What is the output of the following function?

``def function(x):  return 5 +xprint(function(2))print(function(4))print(function(6)) ``
• Option 1
``````7
9
11``````
• Option 2
``````5
5
5
``````

Q3. What is the output of the following code?

``def recursion(k):  if(k>0):    result = k+recursion(k-1)  else:    result = 0  return resultprint(recursion(2))``
• 1
• 3

#### Challenge 21: Sum Elements of a List

``````def sumList(l):
sum = 0
for x in l:
sum += x
return sum``````

#### Challenge 22: Find Maximum in a List (Challenge 1)

``````def findMaximum(list):
maximum = list
for number in list:
if number > maximum:
maximum = number
return maximum``````

#### Challenge 23: Find Maximum in a List (Challenge 2)

``````def findMaximumValueIndex(list):
maximum = list
index = 0
for i, value in enumerate(list):
if value > maximum:
maximum = value
index = i
return [index, maximum]``````

#### Challenge 24: Reverse a List

``````def reverse(list):
length = len(list)
s = length

new_list = [None]*length

for item in list:
s = s - 1
new_list[s] = item
return new_list``````

#### Challenge 25: Check If List Is Sorted

``````def isSorted(list):
flag = 0
i = 1
while i < len(list):
if(list[i] < list[i - 1]): # compare with the previous element
flag = 1
i += 1

if (not flag) :
return True
else :
return False ``````

#### Challenge 26: Find Duplicates in a List

``````def hasDuplicates(list):
flag = 0
for i in range (len(list)):
for j in range (i + 1, len(list)):
if (list[i] == list[j]):
flag = 1
if (flag == 1):
return True
else:
return False``````

#### Challenge 27: Print Even/Odd Numbers in Descending Order

``````def printEvenOdd(n):
while(n>0):
if (n%2==0):
print ("Even number:",n)
else:
print ("Odd number:",n)
n=n-1

``````

#### Quiz 4: Iteration & Loops

Q1. What is the output of the following code?

``for a in "Python":  print (a)``
• Python
• P
y
t
h
o
n

Q2. What is the output of the following code?

``Languages = ["Python", "Java", "R"]for x in Languages:  if x == "Java":    break  print(x) ``
• Python Java R
• Python Java
• Python

Q3. What is the output of the following code?

``i = 1while i < 7:  print(i)  if (i == 3):    break  i += 1``
• Option 1
``````1
2
3
``````
• Option 2
``````1
2
3
4
5
6
``````

Q4. What is the output of the following code?

``i = 1while i <= 7:  i += 1  if (i == 3):    continue  print(i)``
• Option 1
``````1
2
3
``````
• Option 2
``````2
4
5
6
7
8
``````

#### Challenge 28: Determine Size of a Dictionary

``````def lengthDictionary(Students):
return len(Students)``````

#### Challenge 29: Average of Values of Keys in a Dictionary

``````def calculateAvg(ages):
length = len(ages)
return(sum(ages.values()) / length)``````

#### Challenge 30: Return Key With Maximum Value

``````def oldestStudent(ages):
value = list(ages.values())
key = list(ages.keys())
return key[value.index (max(value))]``````

#### Challenge 31: Increment Dictionary Values

``````def updateAges(ages, n):
new_ages = {}
for word in ages:
new_ages[word] = ages[word] + n
return new_ages``````

#### Challenge 32: Size of a Dictionary Within a Dictionary

``````def totalStudents(students):
return(len(students.keys()))``````

#### Challenge 33: Average Values Within Multiple Dictionaries

``````def calculateAverageAge(students):
result = {}
for thing in students.values():
age = thing['age']

``````

#### Challenge 34: Keys Matching in Multiple Dictionaries

``````def find_students(address, students):
names = []
for key, subdict in students.items():
for sublist in subdict.values():
names.append(key)

return sorted(names)``````

#### Quiz 5: Dictionaries

Q1. What is the output of the following code?

``Dict = { 'Dict1': {'Fruitname': 'Mango', 'season': 'Summer'},          'Dict2': {'Fruitname': 'Orange', 'season': 'Winter'}}print(Dict['Dict1']['Fruitname'])print(Dict['Dict2']['season'])  ``
• Mango
Winter
• Orange
Winter

Q2. What is the output of the following code?

``Dict1 = {  "FruitName": "Mango",  "season": "Spring",}Dict1["season"] = "Summer"print(sorted(Dict1.values()))``
• [‘Mango’, ‘Summer’]
• [‘Mango’, ‘Spring’]

Q3. What is the output of the following code?

``Dict1 = {  "FruitName": "Mango",  "season": "Spring",}Dict1.pop("season")print(Dict1.values())``
• dict_values([‘Mango’])
• dict_values([‘Spring’, ‘Mango’])

Q4. What is the output of the following code?

``Dict1 = {  "FruitName": "Mango",  "season": "Spring",}Dict1.clear()print(Dict1)``
• {}
• [‘Mango’,‘Spring’]

#### Challenge 35: Implement a Rectangle Class

``````class Rectangle:
def __init__(self, x1, y1, x2, y2): # class constructor
if x1 < x2 and y1 > y2:
self.x1 = x1 # class variable
self.y1 = y1 # class variable
self.x2 = x2 # class variable
self.y2 = y2 # class variable
else:
print("Incorrect coordinates of the rectangle!")``````

#### Challenge 36: Implement Getter Methods

``````class Rectangle:
def __init__(self, x1, y1, x2, y2): # class constructor
if x1 < x2 and y1 > y2:
self.x1 = x1 # class variable
self.y1 = y1 # class variable
self.x2 = x2 # class variable
self.y2 = y2 # class variable
else:
print("Incorrect coordinates of the rectangle!")

def width(self):
return self.x2 - self.x1

def height(self):
return self.y1 - self.y2``````

#### Challenge 37: Implement Area and Perimeter Member Methods

``````class Rectangle:
def __init__(self, x1, y1, x2, y2): # class constructor
if x1<x2 and y1>y2:
self.x1 = x1 # class variable
self.y1 = y1 # class variable
self.x2 = x2 # class variable
self.y2 = y2 # class variable
else:
print("Incorrect coordinates of the rectangle!")

def width(self):
return self.x2-self.x1

def height(self):
return self.y1-self.y2

def area(self):
return self.width()*self.height()

def perimeter(self):
return 2*self.width()+2*self.height()``````

#### Challenge 38: Implement a Print Method

``````class Rectangle:
def __init__(self, x1, y1, x2, y2): # class constructor
self.x1 = x1 # class variable
self.y1 = y1 # class variable
self.x2 = x2 # class variable
self.y2 = y2 # class variable
def __str__(self):
return(str(self.x1)+', '+str(self.y1)+', '+str(self.x2)+', '+str(self.y2))

#### Challenge 39: Inheritance

``````class Rectangle:
def __init__(self, x1, y1, x2, y2): # class constructor
self.x1 = x1 # class variable
self.y1 = y1 # class variable
self.x2 = x2 # class variable
self.y2 = y2 # class variable

def width(self):
return self.x2 - self.x1

def height(self):
return self.y2 - self.y1

def area(self):
return self.width() * self.height()

class Square(Rectangle):
def __init__(self, x1, y1, length):
x2 = x1 + length
y2 = y1 + length
super().__init__(x1, y1, x2, y2)``````

#### Quiz 6: Classes

Q1. In Python `__init__ `is

• the method associated with extending a list with another list
• the name of the constructor method for a class

Q2. With the following code, which of the options is true?

``class Person:  def __init__(self, fname, lname):    self.firstname = fname    self.lastname = lname  def printname(self):    print(self.firstname, self.lastname)class Student(Person):  def __init__(self, fname, lname, year):    super().__init__(fname, lname)    self.batch= yearx = Student("Alex", "Vice", 2019)x = Student("Anna", "Bate", 2018)print(x.batch)``
• 2019
• 2018

#### Challenge 40: Return Even Numbers From 1 to n

``````class MyRange:
def __init__(self, n):
self.n = n

def __iter__(self):
return self

def next(self):
evenArray = [] # next method returns this list
for i in range(1, self.n+1):
if i % 2 is 0: # checks if number is even
value = i
evenArray.append(i) # adds the even number to the list
else: # number was odd
i+=1
return evenArray

myrange = MyRange(8)
print (myrange.next())``````

#### Challenge 41: Return Numbers From n Down to 0

``````class MyRange:
def __init__(self, n):
self.n = n

def __iter__(self):
return self

def next(self):
myArray = []
for i in range(self.n, -1, -1): # from n to 0
myArray.append(i) # adds the even number to the list
return myArray``````

#### Challenge 42: Return Sequence of Fibonacci Numbers

``````class MyRange:
def __init__(self, n):
self.n = n

def __iter__(self):
return self

def next(self):
myArray = []
for i in range(self.n): # from n to 0
if i == 0 or i == 1:
myArray.append(i) # adds the even number to the list
else:
myArray.append(myArray[i-2]+myArray[i-1])
return myArray

myrange = MyRange(8)
print(myrange.next())``````

#### Challenge 43: Yield Odd Numbers From 1 to n

``````def odd(n):
for value in range(n + 1):
if value % 2 is not 0:
yield value``````

#### Challenge 44: Yield Numbers From n Down to 0

``````def reverse(n):
for value in range(n, -1, -1):
yield value``````

#### Challenge 45: Yield Fibonacci Sequence From 1st to Nth Number

``````def fibonacci(n):
myArray = []
for i in range(n):
if i is 0 or i is 1:
myArray.append(i)
yield i
else:
x = myArray[i-2] + myArray[i-1]
myArray.append(x)
yield x``````

#### Quiz 7: Asynchronous Programming

Q1. Which of the following statements allow you to execute an asynchronous function `myPrint(x)` once?

• Option 1
``````import asyncio
async def myPrint(x):
print(x)
await asyncio.sleep(1)
return

loop = asyncio.get_event_loop()
results = loop.run_until_complete(myPrint(1))
loop.close()
``````
• Option 2
``````import asyncio
async def myPrint(x):
print(x)
await asyncio.sleep(1)
return

loop = asyncio.get_event_loop()
results = loop.run_until_complete(asyncio.gather(myPrint(1))
myPrint(2))
loop.close()

``````

Q2. Which of the following statements allow you to execute an asynchronous function `myPrint(x)` multiple times?

• Option 1
``````import asyncio
async def myPrint(x):
print(x)
await asyncio.sleep(1)
return

loop = asyncio.get_event_loop()
results = loop.run_until_complete(myPrint(1))
loop.close()
``````
• Option 2
``````import asyncio
async def myPrint(x):
print(x)
await asyncio.sleep(1)
return

loop = asyncio.get_event_loop()
results = loop.run_until_complete(asyncio.gather(myPrint(1), myPrint(2)))
loop.close()
``````
##### Conclusion:

I hope this Full Speed Python Educative Quiz Answers would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions