30 Python Programming Questions on Data Types and Variables
Q 1. Assign an integer value to a variable and print its type.
Expected Output:
Q 2. Assign a floating-point value to a variable and print its type.
Expected Output:
Q 3. Assign a string value to a variable and print its type.
Expected Output:
Q 4. Assign a boolean value to a variable and print its type.
Expected Output:
Q 5. Assign a list to a variable and print its type.
Expected Output:
Q 6. Assign a tuple to a variable and print its type.
Expected Output:
Q 7. Assign a dictionary to a variable and print its type.
Expected Output:
Q 8. Assign a set to a variable and print its type.
Expected Output:
Q 9. Assign a None value to a variable and print its type.
Expected Output:
Q 10. Convert an integer to a float and print it.
Expected Output:
10.0
Q 11. Convert a float to an integer and print it.
Expected Output:
10
Q 12. Convert an integer to a string and print it.
Expected Output:
50
Q 13. Convert a string to an integer and print it.
Expected Output:
100
Q 14. Convert a string to a float and print it.
Expected Output:
12.34
Q 15. Convert a float to a string and print it.
Expected Output:
25.67
Q 16. Write a Python program to check the type of a variable after converting it.
Expected Output:
Q 17. Write a Python program to add two integers and print the result.
Q 18. Write a Python program to multiply two floating-point numbers and print the result.
Q 19. Write a Python program to concatenate two strings and print the result.
Q 20. Write a Python program to check if a variable is an integer.
Q 21. Write a Python program to check if a variable is a float.
Q 22. Write a Python program to check if a variable is a string.
Q 23. Write a Python program to convert a list to a tuple.
Q 24. Write a Python program to convert a tuple to a list.
Q 25. Write a Python program to convert a set to a list.
Expected Output:
[1, 2, 3]
Q 26. Write a Python program to convert a dictionary to a list of keys.
Expected Output:
['name', 'age']
Q 27. Write a Python program to convert a dictionary to a list of values.
Expected Output:
['John', 30]
Q 28. Write a Python program to swap two variables using a third variable.
Q 29. Write a Python program to swap two variables without using a third variable.
Q 30. Write a Python program to get the length of a string.
Input: text = "Hello World"
Expected Output:
11
Bikki Singh
Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!