I got some programs that i need help with and it would be awesome if someone can help me out with them. I've been lurking around this site and hopefully someone can help me. Thank you
I m writing a program that should take number n and output it's sum of it.
for example if i enter 5 it should output 55
for far i m getting nothing.. a error of 15.. its adding up the numbers but not ^2 them.
def times(y): sum=0 for i in range(1,y+1): sum+=i return sum def main(): x=input("Enter a number") w=times(x) print w main()
this program is asking for numbers into words.. so far i got this
import string def letters(l): a=str(l) def main(): x=raw_input("Enter some numbers to be written out") mylist= sentinel="*" while (x!=sentinel): y=eval(x) mylist.append(y) x=raw_input("Enter some numbers to be written out") z=letters(mylist) print z main()
but in the program letters.. i was going to put in the if statements like this ..
if x==10: print "ten" if x==9: numnine=x print "nine" if x==8: numeight=x print "eight" if x==7: numseven=x print "seven" if x==6: numsix=x print "six"
but the thing is .. it has to go up to 999 i can write out all the numbers which will take me a whole day but there is got to be a shorter way of doing it
i got to write this program in a recursively way.. where when i enter numbers in a list it should print out the reverse list in a exact way not using built in fuction.. i got it to work using reverse fuction but thats built in ..and i got it to print reverse but its sorting it..
here is the sorting way
import string def reverse(L): m=len(L) for i in range(m-2): for j in range(m-1): if L[j]<L[j+1]: L[j],L[j+1]=L[j+1],L[j] def main(): x=raw_input("Enter numbers to reverse it") mylist= sentinel="*" while (x!=sentinel): y=eval(x) mylist.append(y) x=raw_input("Enter numbers to reverse it") w=reverse(mylist) print w main()
well it was sorting but now its print none
how do i get started with a program to write the A-Z and returns its permutations ..
for example.. write ab.. it prints ab, ba, if i enter abc it print abc bca cab acb n etc
if anyone can help me with this.. .that would be awesome... thank you!!!