The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
i need help with question 2 i dont know how to solve it, i have attached the file, it is due tomorrow night
Â
COMP 1005/1405A (Summer 2016)Assignment 5 of 6Due: Tues, June 7thby 11:55pmFor each question in this assignmentyou will be submitting three files containing source code written in Python 3,that have been compressed into a "zip" file.ThePython sources(i.e., the .py files)should be named "a5q1.py" and"a5q2.py". Thezip file should be named a5.zip. You willsubmit your file using cuLearn.NO LATE ASSIGNMENTS WILL BE ACCEPTEDYou are expected todemonstrate good programming practices at all times(e.g., choosing descriptive variablenames, provide comments in your code, etc.) andyour code may be penalized if it is poorly written. You are alsoexpected todo the necessary preparatory work(i.e., devising an algorithm)before you start coding.PLEASE NOTE: YOU WILL BE ASKED TO PRESENT EITHER PSEUDOCODE OR A FLOWCHART BEFORE YOU WILLRECEIVE ANY ASSISTANCE FROM THE INSTRUCTOR OR A TEACHING ASSISTANTYour program must compile before it will be graded - even if does not address all the items listed for the question.If your program does not compile you will receive a grade of 0 for that question. If you do not address all the itemslisted in the question then, 1) comment your code accordingly, indiciate what part(s) of the question were notaddressed in your assignment, and 2) print a notification to the console indicating the funtion or requirement thathas been omitted.Question 1 – Pascal's Triangle50 MarksFor this question you will write a program that will use loops to print out rows of Pascal's triangle while looking fora specific integer value provided by the user. (Pascal's triangle is a triangular table of coefficients for the expandedbinomial formula.)11 11 2 11 3 3 11 4 6 4 1The formula for getting the kthnumber(when you start counting at 0) in the nthrow is°!±!(°−±)!.This calculation is known as the combination.The exclamation point (!) in that formula is used to indicate a factorial; the factorial of any number x is the productof all the integers from 1 up to an including x. As a clarifying example, since 2! = 1 * 2 = 2 and 4! = 1 * 2 * 3 * 4 = 24,the 2ndnumber (when you start counting at 0) of the 4throw is 4!(2! (4-2)!) = 24 / (2(2)) = 6.You must write a factorial function and a combination functionyourselfand your combination function must callyour factorial function.You may not use global variables and programs that import the math library or userecursion will not be accepted and will receive a mark of zero.(10 Marks each)Your program will begin by asking the user for an integer value to look for in the triangle – you can safely assumethat the user will enter a number but if the user enters a floating-point number your program must print an errormessage and loop back to allow the user to try and enter another number (10 Marks). On the other hand, if the usergives a valid integer (e.g., 6) then your program will start printing complete rows of the triangle until it encounters a6 – once it encounters a 6, your program shouldcomplete the row and then terminate (10 Marks).
-----------