0

how do you do these string thing i dont understand it

30th Aug 2016, 9:39 AM
frozen chips
3 odpowiedzi
+ 2
Ok... For example u want to Print('This game isn't very good') But it will be a mistake coz python doesnt understand where is the string So u need slash before the sign Print('This game isn\'t very good') will Be valid Watch ExampleString code in playground that i made for you
30th Aug 2016, 12:06 PM
Leshark
Leshark - avatar
+ 1
Strings are a type of variable that stores text (you can think of variables as sections of memory that you've claimed for the program and named so that you can use and alter the values stored in them) here's a load of types of variables with examples (you'll cover them all in this course, but I figure it's useful so you can get your head around variables and what a string is and is not): strings: text such as "this is a string", also used for storing phone numbers since the first 0 is important and you don't tend to do maths on them. In python we make a new string by putting the name of the string then = then speech marks (either a pair of double quote marks or single quote marks, it doesn't really matter which but double are generally favoured, I guess because they are a bit more obvious to spot), to include a speech mark in a string and avoid ending the string early, we use a backslash \ before it to tell python not to treat the speech mark as the end of the string myString = "some text value" phoneNumber = "01234 567890" anotherString = "My favourite saying is \"Hello\" " integers: whole numbers like 1,2,3,0,-1,300 etc you can do maths on these but not store letters, in python 3 dividing them will result in a float no matter of the value the result has. myInteger = 3 rabbitAge = 4 bottlesOfBeerOnTheWall = 99 rabbitAgeInFiveYears = rabbitAge + 5 degreesInCircle = 360 numberOfTimesRoundInCircle = 3 degreesTurned = degreeesInCircle * numberOfTimesRoundInCircle floats: decimal numbers like 3.0, 2.3 , 0.0, -5.0 33.23 again you can do maths on these, and are useful where the values need to be represented with decimal places myFloat = 3.0 booleans: True or False, or 1 (meaning True) or 0 (meaning False) - used in decision making such as if a condition is met then do this (if and else statements) There also variables that are collections of variables such as lists, dictionaries and tuples.
1st Sep 2016, 8:13 PM
Phil
Phil - avatar
0
thx so much i could't get past the strings test
1st Sep 2016, 10:28 PM
frozen chips