Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old March 2nd, 2004, 02:54 PM
reaper69 reaper69 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 30 reaper69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Unhappy Does this look right for what I want to do??!!??

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)

Reply With Quote
  #2  
Old March 2nd, 2004, 03:20 PM
Naddel Naddel is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Germany
Posts: 11 Naddel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 17 m 25 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old March 2nd, 2004, 03:42 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 18 m 50 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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
__________________
programming language development: www.netytan.com Hula


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Does this look right for what I want to do??!!??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway