Pythons print() function

Sdílet
Vložit
  • čas přidán 28. 08. 2024
  • Describes the various ways you can use Pythons print function. Also briefly mentions programming style.

Komentáře • 11

  • @Lennardish
    @Lennardish Před 3 lety +4

    Just to stress that I ADORE these lessons!!!!!!!!!!!!

    • @johnphilipjones
      @johnphilipjones  Před 3 lety

      It is good to know the lessons are helping. Thank you for your positive feedback it is appreciated.
      Best wishes
      Phil

  • @tendaisav
    @tendaisav Před 2 lety +1

    These videos are absolutely incredible. You Sir are simply the best!!!

  • @zeeshanakram8751
    @zeeshanakram8751 Před 6 lety +3

    Sir! I noticed that the default behaviour of python when using ',' i.e comma between strings is to put one space automatically even if we are not using sep = ' ' at the end.
    I mean the output of following these two print statement have the same result:
    print("you are",str(18),"so collect your polling card")
    print("you are",str(18),"so collect your polling card",sep=' ')
    I think it should be described for the beginner also. I am using python 3.6.5.
    If i am wrong please make me correct.
    Thanks a lot sir for your awesome videos.

    • @johnphilipjones
      @johnphilipjones  Před 6 lety +2

      You are correct separating with a comma in the way you describe also inserts a space.
      Best wishes
      Phil

  • @J2897Tutorials
    @J2897Tutorials Před 9 lety +4

    Wow! I thought the 'print' command had just one expression. The 'sep' may come in handy when splitting data up.

  • @hadikhederi3483
    @hadikhederi3483 Před 4 lety

    i noticed the print result will be same without str in str(age).
    so we can write print('you are',age,'so collect your polling card')

    • @johnphilipjones
      @johnphilipjones  Před 4 lety

      Yes that is correct. I tend to use inline code such as str() to help comment code.
      Best wishes Phil

  • @Lennardish
    @Lennardish Před 3 lety

    I think that nowadays the sep is no longer necessary. Dont'you get the same result with :
    age = int(input("What is your age ? : ")
    print("You are", age, "so collect your polling card")?

    • @johnphilipjones
      @johnphilipjones  Před 3 lety

      Sep has always been option meaning you can include it It or not included it.
      Best wishes
      Phil