Python Forum
how to make a mathematical operation without the command "print"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to make a mathematical operation without the command "print"
#5
You need to be more specific. Nothing prints unless you tell it to print (except the interpreter). For example:

def mult(A, b):
    result = a * b

    return result

product = mult(2, 3)
will not print anything unless you add a 'print()' function somewhere, either within the mult() function or as a line after calling the mult() function for example:

def mult(A, b):
    result = a * b

    return result

product = mult(2, 3)
print(product)
Note that you do not need to print anything, you could also use the variable 'result' in another computation or function. Remember, the print() function is for humans to see what is happening within a program, not necessarily a requirement. This ability to see is also why the print() function is a valuable tool when trouble shooting.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Messages In This Thread
RE: how to make a mathematical operation without the command "print" - by sparkz_alot - Mar-15-2018, 07:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 756 Apr-18-2024, 07:07 AM
Last Post: Bronjer
  plotting based on the results of mathematical formulas Timur 1 346 Feb-08-2024, 07:22 PM
Last Post: Gribouillis
  problem with print command in super() akbarza 5 593 Feb-01-2024, 12:25 PM
Last Post: deanhystad
  Taking Mathematical Expressions from Strings quest 2 710 Jul-02-2023, 01:38 PM
Last Post: Pedroski55
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 1,085 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  Why does absence of print command outputs quotes in function? Mark17 2 1,381 Jan-04-2022, 07:08 PM
Last Post: ndc85430
  Using print command to send command to rasberry pi terminal MondazeBear 2 1,871 Aug-02-2021, 03:15 PM
Last Post: Larz60+
  How to make print without newline but wait in between each print? Adrian_L 6 3,089 Apr-01-2021, 09:59 PM
Last Post: Adrian_L
  About mathematical equations seyidcemkarakas 3 2,039 Oct-04-2020, 01:21 PM
Last Post: Gribouillis
  Recognising mathematical expressions from word and pdf file Preeti15 0 1,792 Aug-19-2020, 09:06 AM
Last Post: Preeti15

Forum Jump:

User Panel Messages

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