subject

Below we've attempted to write a recursive formula that will calculate the nth triangular number. 1 def tri(n): return n + tri(n - 1) what will be the current result of using this function? it will correctly calculate the nth triangular number oit will instead calculate the n 1th triangular number. it will instead calculate the n +1th triangular number. o it will cause a runtimeerror due to infinite recursion. it will cause a nameerror due to attempting to call try) from within try problem 5.2.2, part 2 of 3 1.0/1.0 point (graded) why does the issue or error in the problem above occur? o no issue occurs; the function correctly calculates the nth triangular number. o the recursive function has no base case, so it never stops calling copies of itself. o the recursive function has no base case, so it never calls a copy of itself. othe recursive function incorrectly calls itself with n -1 as an argument instead of n o the recursive function incorrectly calls itself with n 1 as an argument instead of n1. othe variable n - 1 is not defined when referenced on line 2 which of the following revisions to the function tri) would fix the observed issues? no revision necessary; the original function works. 1| def tri(n): if n == 1: return 1 4else: 5 l return n tri (n-1) 1| def tri(n): 2 if n return n +tri(n-1) 4lse: return 1 1| def tri(n): if n > 1 return 1 4lse return n + tri(n-1) 1| def tri(n): 21f n> 1: return n tri(n-1) 4 else: return1

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
Problems: 1. using textbooks, reference books, and internet as your source of research, draw the following microprocessor microarchitectures i. intel 8086 ii. motorola 68000 i atmel atmega32 iv. mips single cycle v. arm cortex-m3 write an hdl module for a hexadecimal seven-segment display decoder. the input is 4-bit binary representing a hex number (0-f), and the output is 8-bit seven segment display bits (a-h). thus, the decoder must handle the digits 10 - 15 to display a-f respectively, in addition to 0-9 numbers. 2. design a 4-bit left and right rotator (both outputs). first sketch schematic diagrams of your design. then implement your design using hdl coding. 3. 4. design a modified priority encoder that receives an 8-bit input, a7: 0 and produces a 3-bit output, y2o. y indicates the most significant bit of the input that is true. y should be 0 if none of the inputs are true. give a simplified boolean equation, sketch a schematic, and write an hdl code. 5.write an 8: 1 multiplexer module called mux8 with selection inputs s, data input d, and data output y. data input (d) and data output (v) are 32-bit wide
Answers: 3
question
Computers and Technology, 22.06.2019 10:30
You are almost finished updating a web site. as part of the update, you have converted all pages from html 4.0 to html5. the project is currently on schedule. however, your project manager has been asked by the marketing team manager to justify a day of time spent validating the site's html5 pages. the marketing team manager does not have technical knowledge of the internet or the web. which is the most appropriate explanation to provide to the marketing team manager?
Answers: 1
question
Computers and Technology, 22.06.2019 14:50
Drag each label to the correct location on the image list the do’s and don’ts of safeguarding your password. a. keep yourself logged in when you leave your computer.b. don’t write your password down and leave it where others can find it.c. share your password with your friends.d.each time you visit a website,retain the cookies on your computer.e. use a long password with mixed characters.1. do's 2. don'ts
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
File account.java (see previous exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a string representation. note that the constructor for this class creates a random account number. save this class to your directory and study it to see how it works. then write the following additional code: 1. suppose the bank wants to keep track of how many accounts exist. a. declare a private static integer variable numaccounts to hold this value. like all instance and static variables, it will be initialized (to 0, since it’s an int) automatically. b. add code to the constructor to increment this variable every time an account is created. c. add a static method getnumaccounts that returns the total number of accounts. think about why this method should be static - its information is not related to any particular account. d. file testaccounts1.java contains a simple program that creates the specified number of bank accounts then uses the getnumaccounts method to find how many accounts were created. save it to your directory, then use it to test your modified account class.
Answers: 3
You know the right answer?
Below we've attempted to write a recursive formula that will calculate the nth triangular number. 1...
Questions
question
Mathematics, 22.10.2019 18:00
Questions on the website: 13722360