PYTHON Flashcards

1
Q

What are the functions of Python?

A

creating web applications, and workflows, connecting database systems, handling big data

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

pyhton uses____ to complete a command

A

New lines

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

Python relies on _____ to define scope - loops, functions and classes

A

Indentation

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

Does python have a command for declaring a variable?

A

No

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

What is the purpose of comments in Python?

A
  • make code readable
  • explaims code
  • prevents execution or I think error when testing code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to get data type of a variable?

A

type() function

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

______ is the method of specifying a type of variable

A

Casting

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

What are the different kinds of variables? Explain

A

String - A sequence of characters (letters, digits, symbols) enclosed in quotes
Float - Numbers that include a decimal point. They are used for representing real numbers
Integer - Whole numbers, without any decimal points. They can be positive, negative, or zero.

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

b = 14
B= “David”
# B will not overwrite b
What is this an example of?

A

Case-sesntivity

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

What are the rules for python variables?

A
  • must start with a letter or underscore character and not a number
  • can only contain alpha-numeric characters and underscores
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

” You can assign values to multiple variables in one line in python” - T/F

A

True

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

_____ function allows to output variables

A

Print

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

what are strings in python?

A

array of bytes representing unicode characters

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

how can u output multiple variables?

A

Comma and + sign

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

what is the best way to output different kinds of variables using print function?

A

COMMA

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

does python have a character data type?

A

no, a character is a string eith length of one

14
Q

every number is true using bool() fxn except____

A

0

14
Q

Can you convert from one type of numeric variable to another in python?

A

Yes, except not complex numbers that will give an error

14
Q

What are the numeric types in python?

A

float, integer and complex

15
Q

what formula to use to get the exact length of a string?

A

print(x[len(x)-1])

15
Q

How to get the length of a string?

A

using len() function

16
Q

what phrases to use to check certain phrase or character in the string?

A

in or not in

16
Q

how can we access elements or characters of a string?

A

using this bracket type [ ]

16
Q

what are the various in built functions of strings?

A
  1. upper - lower case
  2. replace
  3. split
17
Q
A
17
Q

____ is the technique of getting back a range of characters using a colon to separate

A

Slice syntax
print (a[2:6])

17
Q

_____ helps in knowing if the expression is true or false in python

A

Booleans

18
Q

what do the following python assignment operators mean?
1. x +=5
2. -= 5
3. x*=5
so on and so forth

A
  1. x = x+5
  2. x = x-5
  3. x= x*5
19
Q

What do the following comparison operators imply?

!=
>
<
>=
<=

A

equal
not equal
greater than
less than
greater than or equal to
lower than or equal to

20
Q

Name the python logical operators and their functions

A
  1. and - returns True if both statements are true
  2. OR - returns true if one statement is true
  3. Not - reverses the result
21
Q

What are the python membership operators, explain functions

A
  1. In = returns true if a sequence with the specified values is present. EX: X in Y
  2. not in = returns true if a sequence with a specified value is not present like x not in y
22
Q

the ____ keyword is used for conditional evaluation and the print instruction will only generate when the ____ condition is met

A

IF

23
Q

Python relies on ____________(whitespace at the beginning of a line) to define the scope in the code.

A

indentation

24
Q

____ keyword catches anything which isnt caught by the preceding condition

A

Else
when the if condition evaluates to false, else condition is executed

25
Q

What is the role of the elif keyword?

A

if previous conditions like, for eg value relation b/w 2 numbers is not true, then try this condition and occurs after if and before else condition, can have multiple elif’s