Python Forum
Understanding a piece of code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding a piece of code
#1
def area(x,y = 3.14): # formal parameters
    a = y*x*x
    print (a)
    return a

a = area(10)
print("area",a)
* Here is what I am doing:
3.14 * 3.14 * 3.14 = 30.56476
30.56476 is a
then 30.56476 * 10
305.6476

but the actual answer is: 314.0 ( when you run the program)
buran write Jan-20-2022, 06:48 PM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
Reply


Messages In This Thread
Understanding a piece of code - by Michael1 - Jan-20-2022, 06:25 PM
RE: Understanding a piece of code - by deanhystad - Jan-20-2022, 06:34 PM
RE: Understanding a piece of code - by Michael1 - Jan-20-2022, 06:37 PM
RE: Understanding a piece of code - by deanhystad - Jan-20-2022, 07:11 PM
RE: Understanding a piece of code - by Michael1 - Jan-20-2022, 07:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 728 Sep-05-2023, 12:50 PM
Last Post: ToniE
  First piece of code Bearwulf 2 775 Aug-02-2023, 04:03 PM
Last Post: deanhystad
  Code understanding: Need help in understanding dictionary code jt123 0 478 Jul-09-2023, 01:13 PM
Last Post: jt123
  New to python/coding Need help on Understanding why this code isn't working. Thanks! mat3372 8 1,765 May-09-2023, 08:47 AM
Last Post: buran
  How to make this piece concise leoahum 0 1,350 Sep-23-2021, 09:23 PM
Last Post: leoahum
  .maketrans() - a piece of code which needs some explanation InputOutput007 5 2,999 Jan-28-2021, 05:05 PM
Last Post: buran
  Beginner: I need help understanding few lines of a code. hop_090 1 1,698 Sep-07-2020, 04:02 PM
Last Post: Larz60+
  Extracting Rows From Data Frame and Understanding The Code JoeDainton123 0 1,447 Aug-03-2020, 04:08 PM
Last Post: JoeDainton123
  I am a newbie.Help me with this simple piece of code feynarun 3 2,826 Jan-08-2020, 12:40 PM
Last Post: perfringo
  How can I improve this piece of code? aquerci 3 2,222 Nov-17-2019, 10:57 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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