Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1
- n = input("Enter a number: ")
- if len(n) == 2:
- print("Two-digits")
- else:
- print("No")
- #2
- from math import *
- def func(x): # сама функция
- return (10 - 2 * exp(x)) / (sin(x) + 1)
- array = [] # массив, в котором будем хранить пары (значение, точка)
- for x in range(-10, 11):
- 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")
- for i in fhand:
- if int(i) % 2 == 1:
- print(int(i), sep=" ")
- #4
- fhand = open("test_4_1.txt")
- s = fhand.read()
- s = s.split()
- s = set(s)
- print("Unique words: ", len(s))
- print(*sorted(s))
- #5
- import random
- def func(fhand):
- n = int(input())
- products = ['undergraduate', 'PhD', 'masters']
- f = open(fhand, 'w')
- for i in range(n):
- ind = random.randint(0, 2)
- string = products[ind] + ',' + str(random.randint(1, 50)) + '\n'
- f.write(string)
- func('task_file.txt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement