Loading samples...
Loading samples...
py-sample-2
Understanding Python's Core Data Types
What is the type of 3.14?
Which function converts a value to an integer?
What is the result of type(True)?
Which is a mutable data type?
What is the output of print(type([]))?
Which data type stores key-value pairs?
What is type(5+3j)?
Which operator checks if two values are equal?
What is the boolean value of empty string ''?
Which function returns the memory address of an object?
Differentiate between mutable and immutable data types with two examples each.
[3 marks]Explain type conversion with examples of implicit and explicit conversion.
[3 marks]What are Python's numeric data types? Explain each briefly.
[3 marks]Write the output: print(5 + 3.0). Explain why.
[2 marks]What is None in Python? How is it different from 0 or False?
[3 marks]Explain the difference between is and == operators.
[3 marks]What is the difference between ' and " in Python strings?
[2 marks]How do you create a multiline string in Python?
[2 marks]What are the sequence data types in Python? List them.
[3 marks]Explain the concept of type() function with an example.
[3 marks]Write a program to demonstrate all basic arithmetic operations on two numbers.
[5 marks]Create a program that takes user input and displays its type.
[5 marks]Write a program to convert temperature from Celsius to Fahrenheit.
[5 marks]Create a program that swaps two variables without using a temporary variable.
[5 marks]Write a program to calculate the area and circumference of a circle.
[5 marks]Create a program that demonstrates type casting between int, float, and str.
[5 marks]Find the error: x = '5' y = 10 print(x + y)
[3 marks]Explanation:Cannot add string and int directly. Need to convert x to int first.
Predict output: a = 5 print(type(a)) a = 'hello' print(type(a))
[2 marks]Explanation:Python is dynamically typed. Variable 'a' changes type from int to str.
Find and fix: print = 'Hello' print(print)
[3 marks]Explanation:Don't use built-in function names as variable names. Use different variable name.
Predict output: print(5 / 2) print(5 // 2)
[2 marks]Explanation:/ does float division, // does floor (integer) division.
Find error: value = input('Enter number: ') result = value + 10
[3 marks]Explanation:input() returns string. Convert to int: int(value) + 10.
Predict output: x = None print(bool(x)) print(x == 0) print(x == False)
[3 marks]Explanation:None is falsy but not equal to 0 or False. None is its own type.
Find error: num = 3.14.15
[2 marks]Explanation:Invalid float literal. Numbers can only have one decimal point.
Predict output: a = 5 b = 5.0 print(a == b) print(a is b)
[2 marks]Explanation:== checks value equality, is checks identity. Different types have different memory addresses.