Python General and Specifc Notes
Python General and Specifc Notes
(Python notes)
1.printing: a code that simply prints what is written inside the
parentheses and output it in the console.
!if you forgot one of the quotations you will get the error message
That says{syntax error}when you run your piece of code.
#we changed the double quotes to single quoates of the string for a reason and that is if we didn’t do that the
program would give us an error message because it would read it this way:
Good to note;unless you want the console to print the string after
the(\n)with a space behind it you don’t want to press the space
button after the (\n).(tldr,don’t press space)
Ex/print(“hello\ndear\nbrother”)———>gives..hello
dear
brother
B.string concatenation(+):as the name suggests,it combine two
strings into one without spaces between the strings.
Ex/Print(“hello”+”world”)——>gives..helloworld
Good to note;to seprate two strings you can add spaces. there is 3
ways;
1.add the space to the end of first string Like this print(“hello “+”world”)
2.to the beginning of the first stringLike this print(“hello”+” world”)
3.add a space in the form of another string by
adding another (+) Like this print(“hello”+” “+”world”)
Space in the form of a string
!if you have an extra open parentheses you’ll get the error message
{syntax error;unexpected error while parsing}it simply means that
The computer would still expect you to continue then close the
statement.
2 ways
As input(“”) then assigned this line to
a variable
If you just put
Varaible=input
Print(len(My_name))or
My_name=input(“the name”)
Lenght=len(My_name)
Print(length)
2. Input(“your name is:”)
Len(input(“your name”)
Print(len(input(“your name”) *this is the line of code we write in the shell
The above lines is to demonstrate how python is
reading and excuting the code