top of page

Multi-line printing

You can use triple quotes to print strings on multiple lines in order to make text easier to read, or create a special text-based design.

 
 

My example code as follows

 

secret_number = 777 print( """ +================================+ | Welcome to my game, muggle! | | Enter an integer number | | and guess what number I've | | picked for you. | | So, what is the secret number? | +================================+ """) guessesTaken = 0 while guessesTaken != 777: print('Take a guess.') guess = input() guess = int(guess) guessesTaken = guessesTaken + 1 if guess < secret_number: print('Your guess is too low.') if guess > secret_number: print('Your guess is too high.') if guess == secret_number: break if guess == secret_number: guessesTaken = str(guessesTaken) print('Well done, muggle! You are free now. You guessed my number in ' + guessesTaken + ' guesses!') if guess != secret_number: secret_number = str(secret_number) print('Nope. The number I was thinking of was ' + secret_number)

 

Here is a similar programming as well as other resources about Python:

aboutME

I am John Fan Zhang, a data analyst and finance researcher. I hold a PhD in finance, CFA charter and full membership of CFA New Zealand Society. I have fifteen-year experience in corporate investment and eight-year experience in advanced data analysis. My research focuses on the effect of social psychology (culture) on financial decisions. Finance research involves heaps of data analyses that lead me to the data field. I am a Microsoft Certified Solutions Expert (MCSE): Data Management and Analytics (Excel, Power BI, and SQL). Aside from Excel, Power BI and SQL, I am also familiar with econometric tools such as Stata, Eviews, and MATLAB. I use OX and Python for programming. I am an active data community event participant, volunteer, speaker, moderator, program reviewer, including PASS Marathon 2020, Global AI BootCamp Auckland 2019, SQL Saturday Auckland (2017, 2018, 2019), and Definity Conference (2018, 2019, 2020, Auckland, New Zealand).

Auckland, New Zealand

  • Google Site
  • Twitter
  • LinkedIn

©2016 BY JOHN'S DATA STORY

bottom of page