Python Forum
Syntax for Doubling a number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax for Doubling a number
#1
Hello,

having trouble with some coding:
def double_num(number): 
    # what code is needed to double the contents of the variable number? 

print(double_num(21))
Below is what I am writing but I am getting a syntax error.
def double_num(number): 
    # what code is needed to double the contents of the variable number? 
    return # double_num(21)=21 * 2
number=21
double_num(21)=number * 2
# This line of code allows you to test your answer when you click the Run button
print(double_num(21))
Please help with this
deanhystad write Jan-12-2025, 03:33 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
def double_num(number): 
    # what code is needed to double the contents of the variable number? 
    return number * 2
Reply
#3
If I could ask, how have you been learning Python? A book (which one?) or something else?
Reply
#4
(Jan-12-2025, 08:34 AM)ndc85430 Wrote: If I could ask, how have you been learning Python? A book (which one?) or something else?

Starting on Codefinity. Do you recommend other avenues? Would appreciate any recommendations.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  doubling a number Skaperen 8 2,892 Jul-25-2023, 10:20 PM
Last Post: Skaperen
  Even number code syntax error MrCeez 1 2,943 May-02-2021, 06:43 PM
Last Post: Larz60+
  Lists first item is a number however i cant compare it with an int getting syntax err Sutsro 4 3,309 Apr-22-2020, 10:22 AM
Last Post: Sutsro

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020