The speak () block uses the text-to-speech tool to speak the given text. It will speak the selected voice with the chosen language in the set language to () block. Usage of the block is limited to 128 characters. If a string longer than 128 characters is given, then only the first 128 characters will be spoken.
Implicit type conversion demonstrates how Python automatically converts integers to floats and displays the result and data type.
Introduction:
This Python code illustrates the concept of implicit type conversion in Python. It showcases how Python converts integers to floats automatically and displays the result along with the data type.
Code:
#Implicit type conversion from int to float
num1 = 10 #num1 is an integer
num2 = 20.0 #num2 is a float
sum1 = num1 + num2 #sum1 is sum of a float and an integer
print(sum1)
print(type(sum1))
Logic:
1. The code initializes two variables: ‘num1’ with the value 10 (an integer) and ‘num2’ with the value 20.0 (a float).
2. The code performs addition on ‘num1’ and ‘num2’ and assigns the result to ‘sum1’.
3. The code then prints the value of ‘sum1’ and its data type.
Output:
>> 30.0
>> <class ‘float’>
Read More