Presentation is loading. Please wait.

Presentation is loading. Please wait.

More Strings.

Similar presentations


Presentation on theme: "More Strings."— Presentation transcript:

1 More Strings

2

3 It’s because the multiplication bit (“llo
It’s because the multiplication bit (“llo * 5) is done first, and then added to the string “He”.

4 Challenge Solution – print (“Fred “ *5)
Can you remember how to get your program to print out your name 5 times? Get your program to print “Ha Ha Ho Ho” but you can only type the words once in the program Solution – print (Ha” *2 + “Ho “ * 2) Now add this line to the program & run it Print (“Hello” * 2 + 2) What Happens? 2Hello” is multiplied by 2 giving “HelloHello” 2. 2 is added to the string “HelloHello” Well that’s a problem. Step 2 does not make sense. You can’t add a number to a string, so you should remove it again. Sorry but it is useful to know what happens when a line of code has an error.

5 Challenge 2 Type the following code into python: Print (“**\n**”)
You should see a 2 x 2, a 3x3 and a 4x4 grid of squares Write a program to print a triangle made up of stars Really advanced???? Can you print a Christmas tree? Solution – print (“*\n**\n***\n****”)


Download ppt "More Strings."

Similar presentations


Ads by Google