One Flashcards
Can we use an undefined variable
No, although a variable doesn’t need to be declared. But it has to be defined before we use it.
How to define a complex number
complex_number=real+imagj
The underscore symbol
_ represents the last printed expression
How to quote a string
single and double quotes both work
Raw line option which causes backslash to be silent
print r’something’
Concatenate strings
string1+string2
strings next to each other : This only works with literals though, not with variables or expressions
Repeat strings
number*string
Lists
list_name = [,,,,]
List Concatenation
list_one+list_two
Append variable to list
list_name.append()
Change the content and the size of it
list_name[index]=something
Note: the list cannot be extended this way. The method append must be used.
nesting list
[ list,list2,other variables]
avoid new line printout
print something,
If a Python script is run from another directory, does the searching path include the current directory or the parent directory of the script?
Only the parent directory of the source code is included as a home directory