Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1-name And briefly describe the 3 fundamental types of python variables? 2- What

ID: 3582043 • Letter: 1

Question

1-name And briefly describe the 3 fundamental types of python variables? 2- What is an infinite loop? What causes the infinite loop to occur? Give or describe an example. 3- 4- What’s the purpose of indentation in python? Give or describe an example? 5- Execute the instruction below. Provide a diagram that shows the values of each variable takes? 1. Draw a box, label the box A, wrire the number 1 in box A. 2. Draw a box label the box S , write the number 0 in box S. 3. Draw a line that values may be written on, label the line output. 4. If the number on box A is less than 6 ,do instructions 5-7 Otherwise do instruction 8. 5. Replace the number on box S with the number in box S plus the number in box A. 6. Replace the number in box A with the number that is one more than the number currently in box A. 7. Go back and do instruction 4 again. 8. Write the number on box S on the line labeled output . 9. You are done. 6- Give a high level description of what the algorithm in the previous question accomplishes.(what does the algorithm accomplish?) 7- Explain or define the term algorithm. Give an example of an algorithm. Why your example is an algorithm? Give an example of algorithm. 8- What is the result, give or describe a python example. Clearly indicate the result in your example. 9- What is a side effect? Give or describe a python example clearly indicate the side effect on your example? 10- Write a python function (definition) for a function named cube that takes a single parameter, computes the cube of the parameter value and returns the computed cube? 11- Write an example call for the function of the previous question and a statement that outputs the result of the call? 12- Explain parameter passing. Use an example in your explanation. Use the answers to the previous questions if you want? 13- Add comments to the following code to explain the purpose of the line of code that follow the comment. Execute the algorithm. Provide a diagram that shows the value that each variable takes. What is output? # r = [ 3 , 7 , 5 , 1 , 4 ] # S = len(r) # t = 0 u =0 # while t < s : # u = u + r[t] # t = t + 1 # v = u / t # Print (v) 14- Regarding the previous question; a- What is the purpose of variable u ? What would a better name for variable u be? b- What is the purpose of variable t ? What would be a better name for the variable t be? c- Give a high level description of what the algorithm in the previous question accomplishes? d- If r = [ 3 , 7 , 5 , 1 , 4 ] was instead r = [ ] , would the code still execute properly? Why not. 15- write a python loop that will output the following sequence of values : [ 0 -2 -4 -6 -8 -10 ] 16- answer the following question regarding the following code: Survey = [[‘Iris’ , 6] , [‘Lily’ ,3 ] , [ ‘Tulip’ , 4 ] , [‘Rose’ , 7 ] , [ ‘Daffodil’ , 5]] A. What type is survey? B. What type is survey [1]? C. What is output by print (survey[1])? D. Write code that accesses and outputs the number that follows Rose.( do not write print (7).)? 17- Explain the python program below. Draw a diagram that shows the value of each variable. What is output? u = 77 v = 22 w = ‘77’ x = ‘22’ y = u + v z = w + x print (y) print (z) output(Z): ------------ output(y): ------------ 18- Give the exact output that will occur when the following code is executed. Explain the code? aa = ‘things’ bb = 3 cc = ‘%s : %d’ dd = cc % ( aa, bb ) print (dd) ---------------------------------------------------------------------------------------------------------------- 19- show the use the selection sort on this sequence of numbers: 3 8 5 4 1 . For each iteration put a box around the last unsorted and circle around the greatest value?

Explanation / Answer

1) Fundamental types of python variables are Numbers which can store numeric values, String is a continuous set of characters which are represented in quotation marks and List holds comma separated items and which are enclosed with square brackets.

2) Infinite loop is the loop whose iteration goes endlessly and it happens either due to condition never met or no condition at all.

3) In python there is no explicit begining or specific end and only option is colon or identation of code.Identations is used to create code blocks.