Write Python statements to:
(i) Find the data type of number 12.
(ii) Find the data type of string ‘Hello’
(iii) Find the data type of value represented by a variable Hello.
(iv) Find the address of memory location represented by a variable amount.
(v) Display the string ‘-*-‘ 25 times in a line.
Answers
Answered by
0
Answer:
Answer for (i) and (ii)
A=(input())
B=int
if (A>='A' and A<'Z'):
print ("It's a string")
elif (A>='0' and A<'15'):
print ("It's an integer")
else:
print ("It's a string")
Explanation:
Answered by
1
Answer:
- Data types can be determined using type()
- id() returns address of memory location represented by a variable.
Solution
(with output)
(i)
>>> type(12)
>>> type(12)<class 'int'>
(ii)
>>> type('Hello')
<class 'str'>
(iii)
In this question Hello is a variable so we don't need any kind of quotation mark
>>> type(Hello)
Will return int if it store integer numbers, or float if it stores fractional numbers , str if it stores strings
(iv)
print(id(amount))
As mentioned in Question, amount is a variable whose address of memory location is to be printed so simply use id(amount) and print it
(v)
print('-*-'*25)
For printing in different lines, just add end="\n"
Similar questions