-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvariables_datatypes.py
More file actions
64 lines (44 loc) · 1.28 KB
/
variables_datatypes.py
File metadata and controls
64 lines (44 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name = 'Ahmed'
year = 2023
""" get type of any varaible """
print(type(name)) # type string
print(type(print)) # <class 'builtin_function_or_method'>
""" conversion between types --> type casting """
"""
int x ;
char [] y ;
"""
""" convert int to string ? """
num = 10
num = str(num)
print(num)
""" convert string to int """
# year = '2023'
# year = int(year)
# print(year)
name = 'noha'
# name = int(name) # You cannot convert string to int unless the string ---> is numeric string
# consists only from digits 0 --> 9
# ?
pii = '3.14'
# pii = int(pii)
print(pii)
""" boolean """
# focused = False
# want_to_sleep = True
# print(True and True)
#
# print(True & True)
"""------------------ Logical operators -----------------"""
print("Ahmed" and "iti")
print("Ahmed" and True and 'iti') # iti ---> represent True.
""" and ---> make sure that all the expression parts must evalutates to true ---> then return True"""
print("Ahmed" and ' ' and 10)
# '' ---> Falsy value , ' '---> truly value
# ("Ahmed" and '' and 10) ---> this expression will return with empty string '' --> represent false
print(bool("Ahmed" and '' and 10))
print(bool('noha'))
print(bool(''))
# return True --> return with the first value represent True
print('Mariam' or 'Noha')
print('' or None or False or 0)