I just finish my #WSQ07 program and here it is
https:/
I just finish my #WSQ07 program and here it is
https:/
#WSQ07
in this program i use a while to make the sum of number in a range, need to make a counter, the counter helpme to do that the program finished whit counter get some value.
here is the link: https://github.com/juanheuforico/mastery/blob/master/sumof.py
here is
print(“give me a range of integers to prints the sum of the numbers in that range “)
r1=int(input(“value to star “))
r2=int(input(“value to finish “))
cont= r1
acum=r1
while cont<r2:
cont=cont+1
acum=acum+1
r1=r1+acum
print(r1)
Comments Off on #WSQ07, sum of numbers
Posted in Blogs, Syndicated, TC1014 Blogs
#WSQ07
in this program i use a while to make the sum of number in a range, need to make a counter, the counter helpme to do that the program finished whit counter get some value.
here is the link: https://github.com/juanheuforico/mastery/blob/master/sumof.py
here is
print(“give me a range of integers to prints the sum of the numbers in that range “)
r1=int(input(“value to star “))
r2=int(input(“value to finish “))
cont= r1
acum=r1
while cont<r2:
cont=cont+1
acum=acum+1
r1=r1+acum
print(r1)
Comments Off on #WSQ07, sum of numbers
Posted in Blogs, Syndicated, TC1014 Blogs
Aqui lo que hice fue usar un do while para que se repita el ciclo mientras los numeros sean acomodados correctamente primero el menor y luego el mayor.
Busqué ayuda con un compañero para que me explicara el ciclo for.
Aquí está mi codigo: https:/
I just used a variable with the initial value as the lower bound, and had it to count the loops and sum that into the final sum every loop, until the counting variable was the same value as the upper bound.
Here’s my code:
https:/
Oscar Ricardo López López A01229116
the program has to sum all the integers in range between two numbers given by the user. at first I did it with the range function but the teacher asked for a loop to make the operation so I did it like this.
ask for two integers, one low and one high but if the user enters the a lower number in the high number place the program wont work properly so I added a condition to correct the numbers:
x = low
y = high
if x > y:
x,y = y,x
that will exchange the values between the x and y and so continue the program correctly. now to do the sum i added a variable with a value of 0 and used a while loop:
z = 0
while x != y:
z = z+x
x += 1
that will add x to z and rise x one number to keep the loop until x=y but will stop before the last number, if x=1 and y=5 then the operation would be 1+2+3+4 excluding the high number, to fix this I added a last operation at the end to print the sum the resulting z with the high number y:
print (z+y)
and it’s done.
question – how do I tell the program to ask again for an integer if the user enters a string?
my code in github:
https:/
Comments Off on WSQ07 – sum of numbers
Posted in Blogs, Syndicated, TC1014 Blogs
Comments Off on Wsq07
Posted in Blogs, Syndicated, TC1014 Blogs
Tagged #TC1014, #WSQ07, Programming, Python
Comments Off on Wsq07
Posted in Blogs, Syndicated, TC1014 Blogs
Tagged #TC1014, #WSQ07, Programming, Python