Python Forum
Just need some clarification
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Just need some clarification
#4
What is your confusion about the code? Are you wondering why boston_celtics[1] returns "jaylen" instead of "kemba"? Python indexing starts at 0, not 1.

Are you wondering what boston_celtics = ("kemba", "jaylen", "jayson") does? The () brackets are a way to create a collection called a tuple. Tuples are like lists (which use [] brackets) but they cannot be modified (append, remove or change items).

Are you wondering what print("The second player in boston is %s" %second_player) does?

print is a command that writes to standard output. What is written will appear in the terminal from which this program was run. The "%" is a format character. The % inside the quotes is replaced by the value of second_player when the string is printed. This is one of several variants of print formatting. I prefer using f strings which I think are easier to read: print(f'The second player in boston is {second_player}')
Reply


Messages In This Thread
Just need some clarification - by Tonje - Oct-01-2020, 02:50 PM
RE: Just need some clarification - by Marbelous - Oct-01-2020, 03:18 PM
RE: Just need some clarification - by buran - Oct-01-2020, 03:45 PM
RE: Just need some clarification - by deanhystad - Oct-01-2020, 03:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can I get some clarification on importing functions from external files. wh33t 3 896 Feb-25-2023, 08:07 PM
Last Post: deanhystad
  Looking for clarification related to performance Pymon 5 2,035 Apr-04-2022, 04:47 PM
Last Post: deanhystad
  Read Tensorflow Documentation - Clarification IoannisDem 0 1,166 Aug-20-2021, 10:36 AM
Last Post: IoannisDem
  *args implementation and clarification about tuple status amjass12 10 3,994 Jul-07-2021, 10:29 AM
Last Post: amjass12
  Global Variables - Some Points Needing Clarification. adt 4 2,949 Nov-30-2019, 01:23 PM
Last Post: adt
  Clarification Hammuel 2 2,861 Oct-30-2017, 12:22 PM
Last Post: Hammuel

Forum Jump:

User Panel Messages

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