-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirst.py
28 lines (26 loc) · 1.01 KB
/
first.py
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
var1: str = "Nima"
var2: str = "Parichehr"
robot: str = "technologically"
words: str = "I saw a cat jump over the moon and into the clouds"
#print(var1.upper() + " is in love with " + var2)
#print("days left are {num: .3f}".format(num=100/3))
#print("{} is in love with {}".format(var1, var2).lower())
#print(robot[0:6])
#print()
#print(robot[1::2])
print(words," {}".format(words.split()[3:12:2] ))
print(len(words),len(words.split()))
s1: slice = slice(3,12,2)
print( "words. split is ", words.split()[s1] )
print( '"cat" in words.split is ', "cat" in words.split() )
print( '"cat" not in words.split is ', "cat" not in words.split() )
newwords: str = words.split()
verynewwords: str = " ".join(newwords).upper() # or can put as many space like in between the items
print(newwords, verynewwords)
pay: str = "I receive a total of $5000"
print(pay)
print(pay.split("$"), "first section ", pay.split("$")[0] , "second part ", pay.split("$")[1])
def avg(*args):
return sum(args) // len(args)
print(avg(3))
print(avg(1,2,3,4,100))