September 29, 2015 CSCI 1170 Closed Lab Assignment #1 for Chapter 4 At one college, it has been announced that the tuition will increase by 3 percent each year for the next 5 years. Write a program with a loop that displays the projected semester tuition amount for the next 5 years. SAMPLE RUN #1 Enter the tuition of this year: 8000.00 In 1 year, the tuition will be $8,240.00. In 2 years, the tuition will be $8,487.20. In 3 years, the tuition will be $8,741.82. In 4 years, the tuition will be $9,004.07. In 5 years, the tuition will be $9,274.19. SAMPLE RUN #2 Enter the tuition of this year: 9000.00 In 1 year, the tuition will be $9,270.00. In 2 years, the tuition will be $9,548.10. In 3 years, the tuition will be $9,834.54. In 4 years, the tuition will be $10,129.58. In 5 years, the tuition will be $10,433.47. Instructions: 1. login to ranger 2. cd CLA (This closed lab assignment must be stored in the directory CLA in your class account.) 3. idle3 & (Open a new file and type the program and save as collegeTuition.py in CLA.) 4. Run your program in python shell by click on <F5> key 5. If the program works, then prepare a log file (YourLastNameCollegeTuition.log) including six runs of your program using the following commands. > > > > > > > > script YourLastNameCollegeTuition.log pwd ls –l cat -n collegeTuition.py python3 collegeTuition.py # Sample RUN #1 python3 collegeTuition.py # Sample RUN #2 exit lph YourLastNameCollegeTuition.log” Submission 1. Pick up a printout of your script file (YourLastNameCollegeTuition.log) described above. 2. Circle all Unix commands. 3. Put your name, section number, and your account id at the top right corner of the printout. 4. Turn in the printout to your lab assistant. September 29, 2015 CSCI 1170 Closed Lab Assignment #2 for Chapter 4 The factorial of n is the product of all integers from 1 to n. For example: 7! = 1 x 2 x 3 x 4 x 5 x 6 x 7 = 5,040 Write a program that lets the user enter a series of a nonnegative integers, calculates the factorial of each number, and displays its factorial. SAMPLE RUN #1 Enter a nonnegative integer or -1 to stop: -1 Good bye SAMPLE RUN #2 Enter a nonnegative integer or -1 to stop: -5 Invalid input Enter a nonnegative integer or -1 to stop: -3 Invalid input Enter a nonnegative integer or -1 to stop: 0 0! = 1 Enter a nonnegative integer or -1 to stop: -1 Good bye SAMPLE RUN #3 Enter a nonnegative integer or -1 to stop: -5 Invalid input Enter a nonnegative integer or -1 to stop: 1 1! = 1 Enter a nonnegative integer or -1 to stop: 2 2! = 2 Enter a nonnegative integer or -1 to stop: 10 10! = 3628800 Enter a nonnegative integer or -1 to stop: 50 50! = 30414093201713378043612608166064768844377641568960512000000000000 Enter a nonnegative integer or -1 to stop: -1 Good bye Instructions: 1. login to ranger 2. cd CLA (This closed lab assignment must be stored in the directory CLA in your class account.) 3. idle3 & (Open a new file and type the program and save as factorial.py in CLA.) 4. Run your program in python shell by click on <F5> key 5. If the program works, then prepare a log file (YourLastNameFactorial.log) including six runs of your program using the following commands. > script YourLastNameFactorial.log > pwd > ls –l > cat -n factorial.py > python3 factorial.py # Sample RUN #1 > python3 factorial.py # Sample RUN #2 > python3 factorial.py # Sample RUN #3 > exit > lph YourLastNameFactorial.log” Submission 1. 2. 3. 4. Pick up a printout of your script file (YourLastNameFactorial.log) described above. Circle all Unix commands. Put your name, section number, and your account id at the top right corner of the printout. Turn in the printout to your lab assistant. September 29, 2015 CSCI 1170 Closed Lab Assignment #3 for Chapter 4 Suppose your salary starts with a penny and it doubles each day. Write a program that reads the number of days from the user and displays the salary for each day and the total pay at the end as long as the salary is below $10,000 as shown below in the sample runs. SAMPLE RUN#1 Enter the number of days: 5 Day Salary ------------------------1 $0.01 2 $0.02 3 $0.04 4 $0.08 5 $0.16 Total salary: $0.31 SAMPLE RUN#2 Enter the number of days: 10 Day Salary ------------------------1 $0.01 2 $0.02 3 $0.04 4 $0.08 5 $0.16 6 $0.32 7 $0.64 8 $1.28 9 $2.56 10 $5.12 Total salary: $10.23 SAMPLE RUN#3 Enter the number of days: 35 Day Salary ------------------------1 $0.01 2 $0.02 3 $0.04 4 $0.08 5 $0.16 6 $0.32 7 $0.64 8 $1.28 9 $2.56 10 $5.12 11 $10.24 12 $20.48 13 $40.96 14 $81.92 15 $163.84 16 $327.68 17 $655.36 18 $1,310.72 19 $2,621.44 20 $5,242.88 Total salary: $10,485.75 Instructions: 1. login to ranger 2. cd CLA (This closed lab assignment must be stored in the directory CLA in your class account.) 3. idle3 & (Open a new file and type the program and save as penniesForPay.py in CLA.) 4. Run your program in python shell by click on <F5> key 5. If the program works, then prepare a log file (YourLastNamePenniesForPay.log) including a run of your program using the following commands. > > > > > > > > > script YourLastNamePenniesForPay.log pwd ls –l cat -n penniesForPay.py python3 penniesForPay.py # Sample RUN #1 python3 penniesForPay.py # Sample RUN #2 python3 penniesForPay.py # Sample RUN #3 exit lph YourLastNamePenniesForPay.log” Submission 1. Pick up a printout of your script file (YourLastNamePenniesForPay.log) described above. 2. Circle all Unix commands. 3. Put your name, section number, and your account id at the top right corner of the printout. 4. Turn in the printout to your lab assistant. September 29, 2015 CSCI 1170 Closed Lab Assignment #4 for Chapter 4 Write a program that reads the number of lines from the user and draws the following pattern. You must use a nested-for loop. SAMPLE RUN #1 Enter the number of lines for pattern: 1 ## SAMPLE RUN #2 Enter the number of lines for pattern: 4 ## # # # # # # SAMPLE RUN #3 Enter the number of lines for pattern: 7 ## # # # # # # # # # # # # Instructions: 1. login to ranger 2. cd CLA (This closed lab assignment must be stored in the directory CLA in your class account.) 3. idle3 & (Open a new file and type the program and save as drawPattern.py in CLA.) 4. Run your program in python shell by click on <F5> key 5. If the program works, then prepare a log file (YourLastNameDrawPattern.log) including a run of your program using the following commands. > > > > > > > > > script YourLastNameDrawPattern.log pwd ls –l cat -n drawPattern.py python3 drawPattern.py # Sample RUN #1 python3 drawPattern.py # Sample RUN #2 python3 drawPattern.py # Sample RUN #3 exit lph YourLastNameDrawPattern.log” Submission 1. Pick up a printout of your script file (YourLastNameDrawPattern.log) described above. 2. Circle all Unix commands. 3. Put your name, section number, and your account id at the top right corner of the printout. 4. Turn in the printout to your lab assistant. September 29, 2015 CSCI 1170 Closed Lab Assignment #5 for Chapter 4 Write a program that reads the number of lines from the user and draws the following pattern. You must use a nested while-loop. SAMPLE RUN #1 Enter the number of lines for pattern: 1 # SAMPLE RUN #2 Enter the number of lines for pattern: 4 #### ### ## # SAMPLE RUN #3 Enter the number of lines for pattern: 7 ####### ###### ##### #### ### ## # Instructions: 1. login to ranger 2. cd CLA (This closed lab assignment must be stored in the directory CLA in your class account.) 3. idle3 & (Open a new file and type the program and save as drawTriangle.py in CLA.) 4. Run your program in python shell by click on <F5> key 5. If the program works, then prepare a log file (YourLastNameDrawTriangle.log) including a run of your program using the following commands. > > > > > > > > > script YourLastNameDrawTriangle.log pwd ls –l cat -n drawTriangle.py python3 drawTriangle.py # Sample RUN #1 python3 drawTriangle.py # Sample RUN #2 python3 drawTriangle.py # Sample RUN #3 exit lph YourLastNameDrawTriangle.log” Submission 1. Pick up a printout of your script file (YourLastNameDrawTriangle.log) described above. 2. Circle all Unix commands. 3. Put your name, section number, and your account id at the top right corner of the printout. 4. Turn in the printout to your lab assistant.
© Copyright 2026 Paperzz