-
Notifications
You must be signed in to change notification settings - Fork 0
/
num = '45' # string.py
52 lines (38 loc) · 1.02 KB
/
num = '45' # string.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# def rect(length, width):
# area = length * width
# perimeter = 2 * length + 2 * width
# return area, perimeter #2 values
# x, y = rect(50, 100) #2 variables
# print(x, y)
# def rect(d1, d2):
# area = d1 * d2
# perimeter = 2 * d1 + 2 * d2
# return area, perimeter
# x, y = rect(5, 6)
# print("Area:", x)
# print("Perimeter:", y)
# word = 'motorbike'
# print(word.find('r'))
# book = "1984"
# print(len(book))
# car = {
# 'brand':'BMW',
# 'year': 2018,
# 'color': 'red',
# 'mileage': 15000
# }
# key = input("Enter a key: ") # Prompt the user for a key
# if key in car: # Check if the key exists in the dictionary
# print(car[key]) # Output the corresponding value
# else:
# print("Key not found in the dictionary.") # Output a message if the key does not exist
# nums = (55, 44, 33, 22)
# print(nums[:2][-1])
# def test(func, arg):
# return func(func(arg))
# def mult(x):
# return x * x
# print(test(mult, 2))
# def pure_function(x, y):
# temp = x + 2*y
# return temp / (2*x + y)