
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
3.6 LAB: Number pattern
Write a recursive function called print_num_pattern() to output the following number pattern.
Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached.
For coding simplicity, output a space after every integer, including the last. Do not end output with a newline.
Ex. If the input is:
12 3the output is:
12 9 6 3 0 3 6 9 12![CTU Assignment List
Section 3.6 - CS 219T: Pyth X zy Section 3.6 - CS 219T: Pytho x
Section 3.6 CS 219T: Pythox
Section 3.5 CS 219T: Pyth X
b Answered: Calling a recurs
✰ learn.zybooks.com/zybook/CS219-2203A-03-2203A/chapter/3/section/6
=zyBooks My library > CS 219T: Python Programming home > 3.6: LAB: Number pattern
zyBooks catalog
3.6 LAB: Number pattern
Write a recursive function called print_num_pattern() to output the following number pattern.
Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then
continually add the second integer until the first integer is again reached.
For coding simplicity, output a space after every integer, including the last. Do not end output with a newline.
Ex. If the input is:
12
3
the output is:
12 9 6 3 0 3 6 9 12
409106.2543518.qx3zqy7
LAB
3.6.1: LAB: Number pattern
0/10
ACTIVITY
main.py
Load default template...
1 # TODO: Write recursive print_num_pattern() function
3 if name ==
main":
num1 = int (input())
num2= int(input())
print_num_pattern(num1, num2)]
алашин
2
4
5
6
X +
? Help/FAQ
Stacey Queen
X
:
11:57 PM
6/19/2022](https://content.bartleby.com/qna-images/question/788fc729-a951-45c4-9909-47eea7bbf82f/d464b683-92fb-4913-b60d-176b5e763e96/6e6c1k_thumbnail.png)
Transcribed Image Text:CTU Assignment List
Section 3.6 - CS 219T: Pyth X zy Section 3.6 - CS 219T: Pytho x
Section 3.6 CS 219T: Pythox
Section 3.5 CS 219T: Pyth X
b Answered: Calling a recurs
✰ learn.zybooks.com/zybook/CS219-2203A-03-2203A/chapter/3/section/6
=zyBooks My library > CS 219T: Python Programming home > 3.6: LAB: Number pattern
zyBooks catalog
3.6 LAB: Number pattern
Write a recursive function called print_num_pattern() to output the following number pattern.
Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then
continually add the second integer until the first integer is again reached.
For coding simplicity, output a space after every integer, including the last. Do not end output with a newline.
Ex. If the input is:
12
3
the output is:
12 9 6 3 0 3 6 9 12
409106.2543518.qx3zqy7
LAB
3.6.1: LAB: Number pattern
0/10
ACTIVITY
main.py
Load default template...
1 # TODO: Write recursive print_num_pattern() function
3 if name ==
main":
num1 = int (input())
num2= int(input())
print_num_pattern(num1, num2)]
алашин
2
4
5
6
X +
? Help/FAQ
Stacey Queen
X
:
11:57 PM
6/19/2022
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
Output differs. See highlights below.
Input
17 5
Your output
17 12 7 2 0 2 7 12 17
Expected output
17 12 7 2 -3 2 7 12 17
Solution
by Bartleby Expert
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
Output differs. See highlights below.
Input
17 5
Your output
17 12 7 2 0 2 7 12 17
Expected output
17 12 7 2 -3 2 7 12 17
Solution
by Bartleby Expert
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 4.3.1: Calling a recursive function. Write a statement that calls the recursive function backwards_alphabet() with input starting_letter.Sample output with input: 'f'f e d c b a def backwards_alphabet(curr_letter):if curr_letter == 'a':print(curr_letter)else:print(curr_letter)prev_letter = chr(ord(curr_letter) - 1)backwards_alphabet(prev_letter) starting_letter = input() ''' Your solution goes here '''arrow_forwardIn c++arrow_forwardPart 2: Unroll Write a function called unroll, which takes in a square array of arrays (i.e. a grid with n rows and n columns). An input could look like this: const square = [ [1, 2, 3, 4], [5, 6, 7, 8], ]; [9, 10, 11, 12], [13, 14, 15, 16] unroll should take in such a square array and return a single array containing the values in the square. You should obtain the values by traversing the square in a spiral: from the top- left corner, move all the way to the right, then all the way down, then all the way to the left, then all the way up, and repeat. For the above example, unroll should return [1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10].arrow_forward
- Python 6. Sum of Numbers Design a function that accepts an integer argument and returns the sum of all the integers from 1 up to the number passed as an argument. For example, if 50 is passed as an argument, the function will return the sum of 1, 2, 3, 4, ...50. Use recursion to calculate • the sum.arrow_forwardWrite a RECURSIVE function, without using any loops, that prints the contents of a matrix with 3 columns. The function should take the matrix and the number of rows as arguments. void print_matrix(int arr[][3], int num_rows);arrow_forwardImplement the following function: Code should be written in python.arrow_forward
- . Explain through an example and with tables how the k-means clustering algorithm would cluster a dataset containing 4 objects, each with three coordinates c. Explain using an example how StandardScaler can support clustering.arrow_forwardC++arrow_forwardQ5/ write a program to compute the value of R from X,Y and Z values which are X=[0,1,2......9], Y= [2,4,6,.,20], and Z=(1,3,5,...,19]. Print the values of X,Y,Z, and R as adjacent columns. R = √A²+B²+C² X √x² + y² +2² A = . B=√36X* +9Y²+252² T C = √9+sin³Y+Z MATLABarrow_forward
- 9. Write function getMoveRow to do the following a. Return type integer b. Parameter list i. 1-d character array (i.e. move), size 3 c. Convert the row portion of the player’s move to the associated integer index for the board array d. Example: i. move = ‘b2’ ii. 2 is the row iii. 2 is index 1 in the board array e. Return the row array index that corresponds to the player’s move f. Return a -1 if the row is not valid (i.e. INVALID) 10. Write function getMoveCol to do the following a. Return type integer b. Parameter list i. 1-d character array (i.e. move), size 3 c. Convert the column portion of the player’s move to the associated integer index for the board array d. Example: i. move = ‘b2’ ii. b is the column iii. b is index 1 in the board array e. Return the column array index that corresponds to the player’s move f. Return a -1 if the column is not valid (i.e. INVALID) I am getting an error when entering the code at the very end. please fix it. This is the code in C int…arrow_forward# dates and times with lubridateinstall.packages("nycflights13") library(tidyverse)library(lubridate)library(nycflights13) Qustion: Create a function called date_quarter that accepts any vector of dates as its input and then returns the corresponding quarter for each date Examples: “2019-01-01” should return “Q1” “2011-05-23” should return “Q2” “1978-09-30” should return “Q3” Etc. Use the flight's data set from the nycflights13 package to test your function by creating a new column called quarter using mutate()arrow_forwardQ#8, Recursive letter: Given the following recursive function: 1 def love_letter(n):2 ifn<1:3 print('I Love CS5001 - Yes I do!!!') 4 else: 5 print('Roses are Red, Violets are Blue') 6 love_letter(n - 1) Identify the code lines that contain the base case and describe its purpose How would you modify this code to produce infinite recursion? Write a version of this code that will run forever and/or generate a RecursionError while still printing each message from line 3 and 5 at least once.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education