Commit 44793f38 by likorn

meow

parent 1dc11b66
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6.3rc1 (C:\Users\Paktalin\AppData\Local\Programs\Python\Python36\python.exe)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/lab5.iml" filepath="$PROJECT_DIR$/.idea/lab5.iml" />
</modules>
</component>
</project>
\ No newline at end of file
length = 5
strings = [None] * length
numbers = [None] * length
for i in range(length):
strings[i] = input("Enter a string nr." + str(i + 1) + " ")
print("")
for i in range(length):
numbers[i] = int(input("Enter a number nr." + str(i + 1) + " "))
def number_sum(numbers_f):
sum_f = 0
for n in range(length):
sum_f += numbers_f[n]
print("______\n"
"The sum is " + str(sum_f))
def reverse_strings(strings_f):
# sorry, I'm reversing in this disgusting way :((((
for string in strings_f:
print(string[::-1])
number_sum(numbers)
reverse_strings(strings)
\ No newline at end of file
file = open("C:/Users/likorn/Documents/lab5/task2.txt", "r")
for i in range(3):
print(file.read(10))
print("")
for line in file:
print(line, end='')
file.seek(0)
sum_ch = 0
for line in file:
sum_ch += len(line)
print("\n\nThe number of characters in the text is " + str(sum_ch) + "\n")
file.close()
file = open("C:/Users/likorn/Documents/lab5/task2.txt", "a")
file.write("END TEXT")
file.close()
# to print the text with the added "END TEXT"
# file = open("C:/Users/likorn/Documents/lab5/task2.txt", "r")
# file.seek(0)
# for line in file:
# print(line, end='')
# file.close()
\ No newline at end of file
user_input = input("Please enter a text between 30 and 50 characters\n")
while len(user_input) < 30 or len(user_input) > 50:
user_input = input("The text is too small or too short. Try again\n")
print(str(len(user_input)))
file = open("C:/Users/likorn/Documents/lab5/task3.txt", "w")
file.write(user_input)
file.close()
def check_input():
inp = input("Please write a text with at least 5 commas\n")
commas = 0
for character in inp:
if character == ',':
commas += 1
if commas >= 5:
return inp
else:
print("Your input has less than 5 commas, try again")
check_input()
return inp
def letters_n_digits(array):
for string in array:
letters = 0
digits = 0
for symbol in string:
if symbol.isnumeric():
digits += 1
else:
if symbol != ' ':
letters += 1
print("'" + string + "' has " + str(letters) + " letters (or any symbols) and " + str(digits) + " digits")
user_input = check_input()
split = user_input.split(',')
print(split)
letters_n_digits(split)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment