Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import *
- #2
- def func(x): # сама функция
- return (1 - cos(x)) / exp(x)
- array = [] # массив, в котором будем хранить пары (значение, точка)
- for x in range(-5, 15):
- array.append([func(x), x]) # добавляем все пары в массив
- print("Where the lowest value is reached:", min(array)[1])
- print("The lowest value of the function:", min(array)[0])
- #3
- fhand = open("text_3_1.txt")
- index = 1
- for i in fhand:
- if index % 2 == 0:
- print(int(i), end=" ")
- index += 1
- #4
- fhand = open("test_4_1.txt")
- s = fhand.read()
- s = s.split()
- s1 = list(set(s))
- count = 0
- for word in s1:
- for i in range(len(s)):
- if word == s[i]:
- count += 1
- print(word, count)
- count = 0
- #5
- import random
- def func(fhand):
- n = int(input())
- products = ['apple', 'banana', 'pineapple']
- f = open(fhand, 'w')
- for i in range(n):
- ind = random.randint(0, 2)
- string = products[ind] + ',' + str(random.random()) + '\n'
- f.write(string)
- func('task_file.txt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement