Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    0
    ReputationRep:
    how do you make this code work in python?
    input
    def mystery(n):
    a, b = 0, 1
    while a < n:
    print (a)
    a, b = b, a + b
    • Study Helper
    • Welcome Squad
    Offline

    18
    ReputationRep:
    Study Helper
    Welcome Squad
    (Original post by noahBigG)
    how do you make this code work in python?
    input
    def mystery(n):
    a, b = 0, 1
    while a < n:
    print (a)
    a, b = b, a + b
    I'm not entirely sure what you're trying to do. Is the user entering a number into n?

    Posted from TSR Mobile
    • Thread Starter
    Offline

    0
    ReputationRep:
    (Original post by Andy98)
    I'm not entirely sure what you're trying to do. Is the user entering a number into n?

    Posted from TSR Mobile
    yeah but it just highlights the new value and displays invalid syntax
    Offline

    0
    ReputationRep:
    (Original post by noahBigG)
    how do you make this code work in python?
    input
    def mystery(n):
    a, b = 0, 1
    while a < n:
    print (a)
    a, b = b, a + b
    YO MAH NIGGY! Just make the shell run fib. Just literally run fib (10) underneath
    • Study Helper
    • Welcome Squad
    Offline

    18
    ReputationRep:
    Study Helper
    Welcome Squad
    (Original post by noahBigG)
    yeah but it just highlights the new value and displays invalid syntax
    Well with python to set n = to a user input I'd recommend something like:

    Print("enter a number")
    n=raw_input

    Posted from TSR Mobile
    • Thread Starter
    Offline

    0
    ReputationRep:
    (Original post by Andy98)
    Well with python to set n = to a user input I'd recommend something like:

    Print("enter a number")
    n=raw_input

    Posted from TSR Mobile
    cheers bruh
    Offline

    3
    ReputationRep:
    can somebody show me how to do a flow chart for the code :
    def mystery(n):
    a, b = 0, 1
    while a < n:
    print (a)
    a, b = b, a + b
    Offline

    0
    ReputationRep:
    mystery(n)
    n=any number
    def mystery(n):
    a, b = 0, 1
    while a < n:
    nprint (a)
    a, b = b, a + b
    mystery(10)
    Offline

    3
    ReputationRep:
    loll I did this controlled assessment last month! It was soooooo long.
    Good luck to you guys!
 
 
 
Poll
Do you agree with the PM's proposal to cut tuition fees for some courses?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.