
Concept explainers
Explanation of Solution
a.
Sum of “n” numbers using “while” loop:
Program:
#set the values
s = 0
i = 0
#get the input from the user
n = eval (input ("Enter the n value: "))
#check "i" is greater than or equal to "n"
while i <= n:
#sum all the numbers
s = s + i
#increment the value
...
Explanation of Solution
b.
Sum first “n” odd numbers using “while” loop:
Program:
#set the values
s = 0
i = 1
#get the input from the user
n = eval (input ("Enter the n value: "))
#check "i" is greater than or equal to "n"
while i <= n:
#sum all the numbers
s = s + i
#increment the value
...
Explanation of Solution
c.
Sum of “n” numbers using “while” loop:
Program:
#set the values
s = 0
#check the condition
while True:
#get the input from the user
n= eval(input("Enter a value: "))
#check "n" is equal to 999
if n == 999:
#break the statement
break
�...
Explanation of Solution
d.
Displaying the number of times a whole number “n” can be divided by 2 using “while” loop:
Program:
#get the input from the user
n = int(input("Enter number: "))
#set the value
count = 0
#check "n" is greater than 1
while(n>1):
#divide the "n" by 2
n = n // 2
#incremen...

Want to see the full answer?
Check out a sample textbook solution
Chapter 8 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
- using r language Obtain a bootstrap t confidence interval estimate for the correlation statistic in Example 8.2 (law data in bootstrap).arrow_forwardusing r language Compute a jackknife estimate of the bias and the standard error of the correlation statistic in Example 8.2.arrow_forwardusing r languagearrow_forward
- using r languagearrow_forwardThe assignment here is to write an app using a database named CIT321 with a collection named students; we will provide a CSV file of the data. You need to use Vue.js to display 2 pages. You should know that this assignment is similar, all too similar in fact, to the cars4sale2 example in the lecture notes for Vue.js 2. You should study that program first. If you figure out cars4sale2, then program 6 will be extremely straightforward. It is not my intent do drop a ton of new material here in the last few days of class. The database contains 51 documents. The first rows of the CSV file look like this: sid last_name 1 Astaire first_name Humphrey CIT major hrs_attempted gpa_points 10 34 2 Bacall Katharine EET 40 128 3 Bergman Bette EET 42 97 4 Bogart Cary CIT 11 33 5 Brando James WEB 59 183 6 Cagney Marlon CIT 13 40 GPA is calculated as gpa_points divided by hrs_attempted. GPA points would have been arrived at by adding 4 points for each credit hour of A, 3 points for each credit hour of…arrow_forwardI need help to solve the following case, thank youarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning




