|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I am trying to right a program that allows you to type in any number and it will start at 1 and keep doubleing till it gets to the number just for fun.
Code: def fib(n) input = "Pick a Number", x a, b = 0, 1 while b < n print b; a, b = b, a+b fib(x) |
|
#2
|
|||
|
|||
|
Code:
def fib(n):
n = int(raw_input("Number: "))
b = 1
while b <= n:
print "%d" % int(b)
b = b + 1
fib(n)
Last edited by Naddel : March 2nd, 2004 at 03:31 PM. |
|
#3
|
||||
|
||||
|
Here you have it, just a very simple example... as you said, the number keeps doubleing untill it gets to the limit you supply
![]() Code:
>>> l = int(raw_input('Enter a number '))
Enter a number 100
>>> n = 1
>>> while n <= l:
print n
n = n * 2
1
2
4
8
16
32
64
>>>
Mark |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Does this look right for what I want to do??!!?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|