Uploaded by Caleb Dean

Python Notes

advertisement
Print Function
1.
Print(“Insert”)
Print(“Nut”)
= Nut
2.
Print(“Nut”)
Print(“Nut”)
=
Nut
Nut
3.
\n = Ability to print multiple text on different lines with 1 line of code
Print(“Nut\nNut”)
=
Nut
Nut
Part 3 Is a simplified code of Part 2
4.
No space character
print("Hello" + "Caleb")
= HelloCaleb
5.
print("Hello" + “ “ + "Caleb") print("Hello " + "Caleb")
or
print("Hello " + "Caleb")
= Hello Caleb
5.
print("Day 1 - String Manipulation")
print('String Concatenation is done with the "+" sign.')
print('e.g. print("Hello " + "world")')
print("New lines can be created with a backslash and n.")
when using “ within a string use ‘ in ()
when using ‘ u can use “ in ()
E.g – Line 2 & 3
Input Function
Input(“Insert”)
input("What is your name?")
print("Good Morning " + input("What is your name?"))
= What is your name
- Caleb
= Good Morning Caleb
print(len(input("What is your name? ")))
Print(len(“Insert) = Length of string
= 6 (Insert)
RUN
=
What is your name? Caleb
=5
name = input("What is your name? ")
Turns code prompt into a variable (Name)
name = input("What is your name? ")
print(name)
name = "Caleb"
print(name)
= Caleb
Download