Hi....
If we use len function for string it will print the lenth of the string by calculating value. What if we print a length of integer??..
Let's see in compiler...
If we use Double quote for integer then it is treated as a String....
To over come this need to understand what is data types.
Interger - (123)
Flaot - (123.321)
String - ("Hello World!")
Boolean - true / false
The variable type can be checked with compiler by using type function.
Type casting- Means converting type
num = len(input("Drop a message"))
new_num_char = str(num)
Exersise :
String input to int and add the string values.
Mathamatical Operations:
a = 5
b = 10
sum = a+b
subtract = a-b
multiply = a*b
divide = a/b
power = a ** b
PEMDAS- priority
()
**
*
/
+
BMI - Calculator
Flow division :
print(10//5)
output = 2
without using round or type casting we can achieve int value by using this.
f-String
score = 0
print(f"your score is {0}")
this f string type cast in a quick and easy way.....
Top comments (0)