[Tutor] Fwd: Re: Adding consecutive numbers
Whom Isac
wombingsac at gmail.com
Wed May 6 14:13:31 CEST 2015
Thanks, Steven. I think you are right about those mistake. But you could
tell that the code was incomplete so the interact() was not defined. I have
updated some parts (basically writing from the scratch). I am busy with a
new project and learning how to create GUI app in python, although there
are not enough source to aid me. I will just post the code here for now:
Thanks, Steven. I think you are right about those mistake. But you could
tell that the code was incomplete so the interact() was not defined. I have
updated some parts (basically writing from the scratch). I am busy with a
new project and learning how to create GUI app in python, although there
are not enough source to aid me. I will just post the code here for now:
##Goal: Building a math program.
## two nums will be asked by the user
## they will be added
## condition: num >=o:
## num will continue to be added into a list untill the second number
## For your information, a consequitive sequence of num : num-->1 num1-->
num+1...+n
if __name__=='__main__':
interact()
def interact():
print('''Welcome to My new Math program!!
With this program, you can find the sum of any consequitive numbers.''')
print('So Just add your numbers in following spaces')
## If anybody complaining about this function. I will have to say, that
the coding is incomplete so
## I will first define all my function then def interact() when I am
finishing.
def getting_numbers(first_num, second_num):
x = [] #This is a empty list to store data
y = [] #This is a empty list to store data
"""Getting the user values:"""
first_num =int(input('Please enter your first number: '))
x.append(first_num) # adding the input in x#
second_num =int(input('Please enter your second number: '))
y.append(second_num) # adding the input in x#
z =(x,y) # This is a touple containing both x and y value.
return z
def adding_all(x):
total = 0
for num in x:
total +=num
return total
def remove_letter(x):
if x != len(x):
print('You did not enter a number')
elif x != adding_all(x):
print("Please, donot include letters")
else:
return x
## I think using a while True function to iterate all item in x
would be better.
def adding_number(x,y):
start = x[0]
end = y[0]
new_x = 0
new_x_1 = 0
while x[0]<=y[0] or x[0]<= 0:
if x[0]==0:
new_x+=1
return new_x
elif x[0]>0 or x[0]<y[0]:
new_x_1+=x[0]
return new_x_1
else:
pass
print("You have not input a digit in order, check your\n")
print("I donot know what you mean?")
More information about the Tutor
mailing list