Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code using python idle and follow all the directions and provide answer according to the template below. Please follow all the directions regarding not

image text in transcribedimage text in transcribedimage text in transcribedPlease code using python idle and follow all the directions and provide answer according to the template below. Please follow all the directions regarding not using the prohibited constructs and do not use .append

Q.1 Write a function called range_roller( ) that takes in two parameters N and K, both as integers. The function should do the following using the range( ) function: - Return a list of numbers from N to 2N+1 (maximum if possible) with step size =3, if and only if K=0 - Return a list of numbers from N to 0 (minimum if possible) with step size =2, if and only if K=1 - Return-1 if K is neither 0 nor 1 Two examples are shown below: Input: (9,0) Output: [9,12,15,18] Input: (11,1) Output: [11,9,7,5,3,1] Q.2 Write a function called while_it( ) that takes in no parameters and returns a list of the series, 105,98,91,..,7. Constraint: You have to use a while loop to implement this Q5. Write a function called square_pair( ) that takes in two lists, namely first list and the second list as parameters. The first list would contain a series of integers and the second list would contain the squares of the integers in the first list, at corresponding indexes. The task is to construct and return a list, containing all corresponding pairs of integers and their squares positioned adjacently. Also entries in every pair should be visible in ascending order. Furthermore your function should return -1 if the two input lists are of distinct lengths. Two examples are shown below: Input: ([1,4,2],[1,16,4]) Output: [1,1,4,16,2,4] Input: ([3,5,1],[9,25]) Output:-1 - You are NOT allowed to use the following constructs unless specified in the assignment directions. Using the following constructs will result in 0 (zero) for the entire submission (assignment, timed test, etc.). The restricted items are as follows: - Concepts not discussed in lectures yet - String functions - Member functions - Exceptions (can use) : Ien () and x=x+[y1,y2,y3] - Built-in functions \& types - Exceptions (can use): str( ), readline( ), open(), close( ), write(), read(), range( ), split() - Cannot use append, sort, etc. - Cannot use "Slicing" - Cannot use "list comprehension" - Cannot use "not in" (together) - Cannot use "in" - not allowed with conditionals - Exception (can use): with range () - Cannot use and \{\} - Exception (can use): mathematical operations (multiply \& exponents) - Data type functions - Exceptions (can use): int(), str (), float () - Break - Continue - Nested Constructs - Exceptions (can use): 2-D list - Multiple returns \& Multiple assignments - Recursion (not allowed unless the question explicitly states otherwise) - Functions within functions (Definitions) -- invocation is fine - Default Parameters - Global variables - Keyword as variable names - while true or without proper condition Please code using python idle and follow all the directions and provide answer according to the template below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions