CWP panel
1.Write a Python program to read and print values of variables of different data types#tansche#2023
Code in Pinned Comment
1.Write a Python program to read and print values of variables of different data types.#tansche#2023
[ad_2]
source
# Integer
int_var = int(input("Enter an integer: "))
print("Integer:", int_var)
# Floating-point number
float_var = float(input("Enter a floating-point number: "))
print("Floating-point:", float_var)
# String
string_var = input("Enter a string: ")
print("String:", string_var)
# Boolean
bool_var = bool(input("Enter a boolean (True or False): ")) # This will convert the input string to a boolean
print("Boolean:", bool_var)
# List
list_var = input("Enter a list (comma-separated values): ").split(',')
print("List:", list_var)
# Dictionary (key-value pairs)
key = input("Enter a key for a dictionary: ")
value = input("Enter a value for the dictionary: ")
dict_var = {key: value}
print("Dictionary:", dict_var)