IX Notes(Python)
IX Notes(Python)
II.True or false
1. Identifiers must start with a letter or slash. (False)
2.Identifiers can contain only letters, digits and underscore.(Ture)
3. Identifiers cannot be the same as Python keywords.(True)
4. Identifiers should be descriptive and meaningful.(True)
5. Can Python allow to assign single value to several variables, with example?
A. Python allows you assign a single value to several variables simultaneously with the “=” operatot.
Example:-
x=y=z=100
print(x)
print(y)
print(z)
DATA TYPES – I & II DAY-6 & 7
I. Fill in the blanks
1. Data types are used to define the type of a variable or an object.
2. Strings are sequences of Characters.
3. Lists contain items of the different data types.
4. Tuples are enclosed in parentheses.
5. Dictionaries are unordered collections of key pairs.
Tuples: cords=93,40
colors=(“red”,”green”,”blue”)
Dictionaries: person={“name”:”John”,”age”:30}
word_count=(“red”,”green”,”blue”)
Boolean: is_active=True
is_valid=False
Sets: fruits={“apple”,”banana”,”orange”}
TYPE CONVERSION DAY-8
I. Fill in the blanks
1. Type conversion is the processes of converting one data type to another.
2. While converting data types value should be compatible with the target data type.
3. Sets and directories are mutable.
4. Tuples and strings are immutable.
5. In Python int(), float(),list(), set(), dict() and bool() are built-in-functions.
2. Give examples to convert float(), int(), tuple(), list() and set() function?
A.
Set: x={“a”,1,”b”:2}
y=set(x)
print(y)
output: {‘a’,’b’}
INPUT FUNCTION DAY-9
I. Fill in the blanks
1. In Python the input() function is used to get input from the user.
2. Input() is a built-in function that stops the execution of the program.
3. The entered text will be stored in variable name.
4. It is important to validate the input to avoid injection attacks.
5.To use it to get numeric input by converting the returned string to a numeric data type.