In Python R5.1 Consider the function call len(\"black boxes\"). How many argumen
ID: 3741194 • Letter: I
Question
In Python R5.1 Consider the function call len("black boxes"). How many arguments are passed to the function? What is the return value? R5.2 In which sequence are the lines of the cubes.py program in Section 5.2 executed, starting with the first line of main? R5.3 Write function headers with comments for the tasks described below. Computing the larger of two integers Computing the smallest of three floating-point numbers Checking whether an integer is a prime number, returning True if it is and False otherwise Checking whether a string is contained inside another string Computing the balance of an account with a given initial balance, an annual interest rate, and a a. b. c. d. e. number of years of earning interest f. Printing the balance of an account with a given initial balance and an annual interest rate over a given number of years Printing the calendar for a given month and year Computing the day of the week for a given day, month, and year (as a string such as "Monday") Generating a random integer between 1 and n g. h. i.Explanation / Answer
If you post more than 1 question, as per chegg guidelines I have to solve only first question ans if you post more than 4 parts in a question, I have to solve only first 4 parts.
Ques 1. Only one argument of type string is passed into the function.
Also, the function returns the length of the string argument, so the return type is integer.
Ques 3. (a)
def largest( a, b ):
if a > b:
return a
return b
(b)
def smallest( a, b, c ):
# if a is smallest
if a < b and a < c:
return a
# if b is smallest
elif b < a and b < c:
return b
else:
return c
(c)
def isPrime(n):
if n < 2:
return False
# 2 is only even prime
if n == 2:
return True
# if n is even number
if int(n % 2) == 0:
return False
for i in range(3, n):
# if n is divisible by i
if int( n % i ) == 0:
return False
return True
(d)
# return true if str1 is inside str2
def contains(str1, str2):
if str1 in str2:
return True
return False
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.