Introduction to Programming using Python - Fall 2003
CSCI 151 Fall 2015 Test 3 PrepDate: November 6, 2015 Open book, open notes, NO CELLPHONES. YOU ARE NOT ALLOWED TO USE PUTTY FOR PART ITEST 3 consists of Two Parts Part I - 20 points – 1 short questions Part II - 80 points - 1 program writing question SAMPLE PART I Question 1Trace the following program and write the program output i = 0while (i<=10):print(“HELLO”)i = i +4print(“DONE”)SAMPLE PART I Question 2Trace the following program and write the program output sum = 0i = 2while (i<=10):sum = sum + ii = i + 3print(sum)SAMPLE PART I Question 3 Trace the following program and write the program output Explain, what this program is calculating num = 356793sum = 0i=1while (i<=6):k = num % 10sum = sum + knum = num / 10i = i + 1print(sum/6)SAMPLE PART I Question 4 Trace your program and write an output for the following input sequence: 12 345 6189 27 0Explain what this program is calculating.num = int(input(“enter number “))a= 0b= 0while(num!=0):k=num%10a=a+kb=b+1num = int(input(“enter number “)) if(b>0):c= a /bprint(a,b,c)else:print(“try again”)SAMLE Part II Q1. Student takes certain amount of courses during the academic year. Write a function that has one parameter - number of courses. The function reads final grade for each course, and returns the average final grade for the academic year. Write a program to test your function Q2. Write a function that accepts one parameter, positive integer, and finds and returns the average of its EVEN digits. If there are no even digits in the parameter, the function returns -1 Write a main function to test your function Q3. Write a function that doesn’t have any parameters. Function reads a sequence of non-zero integers. First zero value will terminate the input. The function finds and returns the number, sum, and average of the negative numbers. Pay attention on the special case of NO NEGATIVE numbers in your input. Write a program to test your function. Example: Input: 2 -5 6 7 -8 -9 0Output: there are 3 negative numbers, their sum is -22 and their average is -7.333333 ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- introduction to programming using python fall 2003
- student lab 1 input processing and output
- python programming project university of south alabama
- microsoft word python class room diary
- python murray state information systems
- lab noland s baker college e portfolio
- chapter 1 scalar variables and data types
Related searches
- introduction to java programming pdf
- introduction to java programming and data structures
- introduction to java programming 10th
- introduction to java programming liang
- introduction to java programming ppt
- introduction to python pdf
- using python in bash
- using python on windows 10
- introduction to java programming liang pdf
- introduction to r programming pdf
- sum of squared error using python functions
- introduction to python programming pdf