1. The use of ( ) around numbers means to calculate them first. 2. use an asterisk * when you want to multiply. 3. Main Operators + addition - subtraction * Multiplication / division ** to the power of ( EX: n = 10 print(n**2) means 10 to the power of 2 (10 squared) ) 4. some of the maths operators in Python also work on strings. Works with addition and multiplication but not subtraction and division. 5. We can find out how long a string is using the len function: print(len('Hello World!')) Note: len function counts all the characters, including the 5 letters in "Hello", the space, the 5 letters in "World", and the exclamation mark. 6. numbers and strings are treated differently in Python because they are different types of information. input always gives us back a string regardless of what the user enters. 7. concatenation: Adding two strings together. 8. You can convert a string to an integer (a whole number) with the int function. to use a string as a number you must first convert it to one. Ex: number = int(input('Enter a number: ')) new_number = number - 1 print(new_number)
9. if you want to read user input as a string, use: s = input('Enter your name: ') but, if you are reading user input as a number, use: n = int(input('Enter a number: '))
10. Passing in multipleargumentsto the printfunction, by using a comma (,) to separate them. When you do this, a space is automatically inserted between each expression. When you are passing multiple arguments to the print function (using a comma to separate them)
11. we cannot add a string and an integer instead we need to use the str function to turn the integer back to a string.
12. Sometimes you'll need to print out longer messages which will extend over multiple lines. To do this you can use strings with triple single or double quotation marks (''' or """).
13. The easiest way to write a long program is to break it down into steps.
Apply: example 1: In your travels through Europe you come across a rabbit with the useful ability to repeat everything you say, as many times as you want. Write a program to control this rabbit. Your program should work like this: What do you want me to say? burb How many times do you want me to say it? 5 burbburbburbburbburb
example 2: Write a program that reads in a number (integer) as input, adds 4 to it, and then prints out the result. Here is an example interaction between your program and the user: Please enter a number: 3 7