Results 1 to 4 of 4

Thread: coding question

  1. #1
    Lesser Wizard MMSTYLE's Avatar
    Join Date
    Oct 2018
    Location
    hogwarts
    Posts
    374

    Default coding question

    so to the forumers out there that have studied python I'm kind of stuck in this task.
    'compute 27 modulo 4 and save the value to my_team'
    so I set the variable as the result of the modulo operation?
    my_team = print(27 % 4) but that's an invalid code.
    Goodbye.

  2. #2
    Master Sorcerer
    Join Date
    May 2016
    Posts
    892

    Default

    I don't know Python, so this may NOT BE RIGHT, but from my understanding and experience in other languages
    Code:
    my_team = print(27 % 4)
    In this piece of code, you have assigned the print function to a variable. You can't do that; instead do:

    Code:
    my_team = 27 % 4  
    print(my_team)
    This saves the result of 27 % 4 to my_team variable, only then you may print the variable.

    What you tried to do is basically assign a task (print the result of 27 % 4) to a variable; you can't do that. Variables store data.
    Try this and tell me if it worked; again, I don't know Python, this is purely from my experience with other languages

    EDIT: Asked a friend who's more familiar with Python than I am, and yeah, it's right
    Last edited by houzteR; 05-15-2019 at 06:05 PM.

  3. #3
    Master Sorcerer Ohlid's Avatar
    Join Date
    Aug 2017
    Location
    in Gummibear64
    Posts
    979

    Default

    Quote Originally Posted by houzteR View Post
    I don't know Python, so this may NOT BE RIGHT, but from my understanding and experience in other languages
    Code:
    my_team = print(27 % 4)
    In this piece of code, you have assigned the print function to a variable. You can't do that; instead do:

    Code:
    my_team = 27 % 4  
    print(my_team)
    This saves the result of 27 % 4 to my_team variable, only then you may print the variable.

    What you tried to do is basically assign a task (print the result of 27 % 4) to a variable; you can't do that. Variables store data.
    Try this and tell me if it worked; again, I don't know Python, this is purely from my experience with other languages

    EDIT: Asked a friend who's more familiar with Python than I am, and yeah, it's right
    ^
    This is correct. You simply set your variable to the result of the operation and print it.
    Been playing Growtopia since 2010.

    I am a proud Hakmarian — the pope in fact!

    Contact Info:

  4. #4
    Lesser Wizard MMSTYLE's Avatar
    Join Date
    Oct 2018
    Location
    hogwarts
    Posts
    374

    Default

    Quote Originally Posted by Ohlid View Post
    ^
    This is correct. You simply set your variable to the result of the operation and print it.
    alright, thanks
    Goodbye.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •