One Flashcards

1
Q

Can we use an undefined variable

A

No, although a variable doesn’t need to be declared. But it has to be defined before we use it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to define a complex number

A

complex_number=real+imagj

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The underscore symbol

A

_ represents the last printed expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to quote a string

A

single and double quotes both work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Raw line option which causes backslash to be silent

A

print r’something’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Concatenate strings

A

string1+string2

strings next to each other : This only works with literals though, not with variables or expressions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Repeat strings

A

number*string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Lists

A

list_name = [,,,,]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

List Concatenation

A

list_one+list_two

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Append variable to list

A

list_name.append()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Change the content and the size of it

A

list_name[index]=something

Note: the list cannot be extended this way. The method append must be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

nesting list

A

[ list,list2,other variables]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

avoid new line printout

A

print something,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

If a Python script is run from another directory, does the searching path include the current directory or the parent directory of the script?

A

Only the parent directory of the source code is included as a home directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly