├── .DS_Store ├── Lecture1_HW ├── Task1to3.txt ├── Task4.py ├── Task5.py └── Task6.py ├── Lecture2_HW ├── Task_Dictionaries.py ├── Task_Lists.py ├── Task_Sets.py └── Task_Tuples.py ├── Lesson3 ├── files │ ├── 3.1-Files.html │ ├── HW3.txt │ ├── car.png │ ├── data.txt │ ├── hw_data.txt │ ├── jack.png │ ├── jack_russell.png │ ├── new.txt │ ├── not_existing_users.txt │ ├── reversed_users.txt │ ├── some_data.txt │ ├── users.json │ ├── users.txt │ └── words.txt ├── homework.py ├── some_data.txt ├── task2.txt ├── task3.txt ├── task4.txt └── task8.txt ├── Lesson4 └── homework.py └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Evangard/Python_Lessons/2be5f6ca323a5441fff399d1f336fc04c0db74c4/.DS_Store -------------------------------------------------------------------------------- /Lecture1_HW/Task1to3.txt: -------------------------------------------------------------------------------- 1 | 1) What type of numbers exist in Python? 2 | integers, floating point numbers, and complex numbers 3 | 4 | 2) What is the max number in Python? 5 | No limit in Python3, it depends on the amount of memory your system has 6 | 7 | 8 | 3) What is dynamic typing? 9 | a compiler or an interpreter assigns a type to all the variables at runtime -------------------------------------------------------------------------------- /Lecture1_HW/Task4.py: -------------------------------------------------------------------------------- 1 | # Create three strings using different quotes 2 | print("First string with double quotes\n", 3 | 'Second string with single quotes\n', 4 | "Using different quotes: 'Hello'") 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Lecture1_HW/Task5.py: -------------------------------------------------------------------------------- 1 | # Given a string - “Hello, this is just a simple string for testing”. 2 | # Make this string lower-cased, reverse all the separate words and take the last word out of it. Assign this word to a variable. 3 | text = "Hello, this is just a simple string for testing"[::-1].lower().split() 4 | last_word = text[len(text)-1] 5 | print(last_word) -------------------------------------------------------------------------------- /Lecture1_HW/Task6.py: -------------------------------------------------------------------------------- 1 | # Given a url: 2 | # https://localhost:8080/query?username=Dmytro&phone=1234567890 3 | # Using string methods extract from this url username and phone number 4 | # and assign them to the separate variables ‘username’ and ‘phone’ accordingly 5 | 6 | user_data = "https://localhost:8080/query?username=Dmytro&phone=1234567890".split("?")[1].split("&") 7 | username = user_data[0].split("=")[1] 8 | phone = user_data[1].split("=")[1] 9 | 10 | print(user_data) 11 | print(username) 12 | print(phone) -------------------------------------------------------------------------------- /Lecture2_HW/Task_Dictionaries.py: -------------------------------------------------------------------------------- 1 | #Dictionaries: 2 | 3 | print("Task 1: Dictionary Creation and Elements") 4 | #Create a dictionary named my_dict that contains the following key-value pairs: 5 | #"name" as the key and "John" as the value. 6 | #"age" as the key and 25 as the value. 7 | #"country" as the key and "USA" as the value. 8 | 9 | my_dict = { 10 | "name": "John", 11 | "age": 25, 12 | "country": "USA"} 13 | #Print the dictionary. 14 | print(my_dict) 15 | 16 | print("Task 2: Access Dictionary Values") 17 | #Given the dictionary my_dict = {"name": "Alice", "age": 28, "country": "Canada"}, access and print the value associated with the key "age". 18 | my_dict = {"name": "Alice", "age": 28, "country": "Canada"} 19 | print(my_dict["age"]) 20 | 21 | print("Task 3: Dictionary Operations") 22 | #Given the dictionary my_dict = {"a": 1, "b": 2, "c": 3}, perform the following operations and print the results: 23 | my_dict = {"a": 1, "b": 2, "c": 3} 24 | 25 | #Add a new key-value pair "d" with the value 4. 26 | my_dict["d"] = 4 27 | #Update the value of key "b" to 5. 28 | my_dict["b"] = 5 29 | #Remove the key-value pair with the key "c". 30 | my_dict.pop("c") 31 | print(my_dict) 32 | 33 | print("Task 4: Dictionary Length") 34 | #Given a dictionary my_dict = {"name": "Alice", "age": 28, "country": "Canada"}, print the number of key-value pairs in the dictionary. 35 | my_dict = {"name": "Alice", "age": 28, "country": "Canada"} 36 | for keys, values in my_dict.items(): 37 | print(str(keys) + ":", str(values)) 38 | 39 | print("Task 5: Dictionary Keys and Values") 40 | #Given the dictionary my_dict = {"a": 1, "b": 2, "c": 3}, print all the keys and values of the dictionary separately. 41 | my_dict = {"a": 1, "b": 2, "c": 3} 42 | print("Keys: ") 43 | for keys in my_dict.keys(): 44 | print(keys) 45 | print("Values: ") 46 | for values in my_dict.values(): 47 | print(values) 48 | 49 | 50 | print("Task 6: Dictionary Sorting") 51 | #Given the dictionary my_dict = {"b": 2, "c": 1, "a": 3}, print the dictionary after sorting it based on the keys in ascending order. 52 | my_dict = {"b": 2, "c": 1, "a": 3} 53 | sorted_dict = dict(sorted(my_dict.items())) 54 | print(sorted_dict) 55 | 56 | print("Task 7: Dictionary Merging") 57 | #Given two dictionaries dict1 = {"a": 1, "b": 2} and dict2 = {"c": 3, "d": 4}, merge them into a single dictionary named merged_dict. Print the merged dictionary. 58 | dict1 = {"a": 1, "b": 2} 59 | dict2 = {"c": 3, "d": 4} 60 | 61 | merged_dict = {**dict1, **dict2} 62 | print(merged_dict) 63 | 64 | print("Task 8: Dictionary Nesting") 65 | #Create a dictionary named student that contains the following information: 66 | 67 | #"name" as the key with the value "Alice". 68 | #"age" as the key with the value 20. 69 | #"grades" as the key with the value [85, 92, 78]. 70 | #Print the dictionary. 71 | student = { 72 | "name": "Alice", 73 | "age": 20, 74 | "grades": [85, 92, 78] 75 | } 76 | print(student) 77 | 78 | print("Task 9: Dictionary Key Existence") 79 | #Given a dictionary my_dict = {"name": "Alice", "age": 28, "country": "Canada"}, check if the key "country" exists in the dictionary. Print True if it does, and False otherwise. 80 | my_dict = {"name": "Alice", "age": 28, "country": "Canada"} 81 | print("country" in my_dict) 82 | 83 | print("Task 10: Dictionary Conversion") 84 | #Given a list of tuples my_list = [("a", 1), ("b", 2), ("c", 3)], convert it into a dictionary named my_dict. Print the resulting dictionary. 85 | my_list = [("a", 1), ("b", 2), ("c", 3)] 86 | my_dict = dict(my_list) 87 | print(my_dict) -------------------------------------------------------------------------------- /Lecture2_HW/Task_Lists.py: -------------------------------------------------------------------------------- 1 | # Task 1: Create a new list with numbers between 100 and 200 that can be devided by 3. 2 | my_list = [x for x in range(100, 300) if x%3 == 0] 3 | print(my_list) 4 | # Task 2: Given a list [13, 59, 56, 13, 84, 58, 43, 4, 74, 8, 32, 100, 92, 50, 29, 24, 61, 39, 99, 45]. Find the maximum and minumum numbers in this list. 5 | 6 | my_list1 = [13, 59, 56, 13, 84, 58, 43, 4, 74, 8, 32, 100, 92, 50, 29, 24, 61, 39, 99, 45] 7 | print(max(my_list1)) 8 | print(min(my_list1)) 9 | 10 | # Task 3: Given a list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. Reverse this list in place without creation a new list. Print the result to the console. 11 | my_list2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 12 | my_list2.reverse() 13 | print(my_list2) 14 | 15 | # Task 4: Given a list with duplicates [1, 2, 3, 4, 3, 1, 5, 2, 6]. 16 | # You need to create a new list with all the duplicate elements removed. 17 | # The order of the elements should be preserved. For example, if the input list is [1, 2, 2, 3, 4, 1, 5],result will be [1, 2, 3, 4, 5]. 18 | my_list_with_dupl = [1, 2, 3, 4, 3, 1, 5, 2, 6] 19 | my_list_without_duplicates = [] 20 | [my_list_without_duplicates.append(x) for x in my_list_with_dupl if x not in my_list_without_duplicates] 21 | print(my_list_without_duplicates) 22 | 23 | # Task 5: Using list comprehension create a list that contains numbers from 10 to 1 in descending order. 24 | numbers = [x for x in reversed(range(1, 10))] 25 | print(numbers) 26 | 27 | # Task 6: Given a list [13, 59, 56, 13, 84, 58, 43, 4, 74, 8, 32, 100, 92, 50, 29, 24, 61, 39, 99, 45]. 28 | # You need to sort it in ascending order using any sorting algorithm. Do not user built-in "sort" or "sorted" method. 29 | my_list3 = [13, 59, 56, 13, 84, 58, 43, 4, 74, 8, 32, 100, 92, 50, 29, 24, 61, 39, 99, 45] 30 | for i in range(len(my_list3)): 31 | for j in range(i+1, len(my_list3)): 32 | if my_list3[i] > my_list3[j]: 33 | my_list3[i], my_list3[j] = my_list3[j], my_list3[i] 34 | print(my_list3) 35 | 36 | -------------------------------------------------------------------------------- /Lecture2_HW/Task_Sets.py: -------------------------------------------------------------------------------- 1 | #Sets: 2 | 3 | #Task 1: Set Creation and Elements 4 | #Create a set named my_set that contains the following elements: 1, 2, 3, 4, 5. Print the set. 5 | my_set = {1, 2, 3, 4, 5} 6 | print(my_set) 7 | 8 | #Task 2: Set Operations 9 | #Given two sets set1 = {1, 2, 3, 4} and set2 = {3, 4, 5, 6}, perform the following set operations and print the results: 10 | set1 = {1, 2, 3, 4} 11 | set2 = {3, 4, 5, 6} 12 | #Union: Combine the elements from both sets without duplicates. 13 | set3 = set1 | set2 14 | set4 = set1.union(set2) 15 | print(set3) 16 | print(set4) 17 | 18 | #Intersection: Find the common elements between the two sets. 19 | print(set1 & set2) 20 | print(set1.intersection(set2)) 21 | 22 | #Difference: Find the elements that are in set1 but not in set2. 23 | print(set1 - set2) 24 | print(set1.difference(set2)) 25 | 26 | #Task 3: Set Membership 27 | #Given a set my_set = {1, 2, 3, 4, 5}, check if the value 3 is present in the set. Print True if it is, and False otherwise. 28 | print(3 in my_set) 29 | 30 | #Task 4: Set Length 31 | #Given a set my_set = {"apple", "banana", "cherry", "durian"}, print the number of elements in the set. 32 | my_set1 = {"apple", "banana", "cherry", "durian"} 33 | print("Set Length: " + str(len(my_set1))) 34 | 35 | #Task 5: Set Addition and Removal 36 | #Given an empty set my_set, perform the following operations and print the resulting set after each step: 37 | my_set3 = set() 38 | 39 | #Add the element "apple" to the set. 40 | my_set3.add("apple") 41 | print(my_set3) 42 | #Add the elements "banana" and "cherry" to the set. 43 | my_set3.add("banana") 44 | my_set3.add("cherry") 45 | #Remove the element "apple" from the set. 46 | my_set3.remove("apple") 47 | print(my_set3) 48 | 49 | #Task 6: Set Intersection Update 50 | #Given two sets set1 = {1, 2, 3, 4} and set2 = {3, 4, 5, 6}, use the appropriate set method to update set1 with the elements that are common between set1 and set2. Print the updated set1. 51 | set1.intersection_update(set2) 52 | print("Intersection: " + str(set1)) 53 | 54 | #Task 7: Set Symmetric Difference 55 | #Given two sets set1 = {1, 2, 3, 4} and set2 = {3, 4, 5, 6}, calculate and print the symmetric difference between the two sets. 56 | set1 = {1, 2, 3, 4} 57 | set2 = {3, 4, 5, 6} 58 | set1.symmetric_difference_update(set2) 59 | print("Symmetric difference: " + str(set1)) 60 | 61 | #Task 8: Set Subset Check 62 | #Given two sets set1 = {1, 2, 3} and set2 = {1, 2, 3, 4, 5}, check if set1 is a subset of set2. Print True if it is, and False otherwise. 63 | set1 = {1, 2, 3} 64 | set2 = {1, 2, 3, 4, 5} 65 | print("Subset: " + str(set1.issubset(set2))) 66 | 67 | #Task 9: Set FrozenSet 68 | #Explain the concept of a frozen set in Python and discuss its characteristics and use cases. 69 | # Frozen set is just an immutable version of a Python set object. 70 | # While elements of a set can be modified at any time, elements of the frozen set remain the same after creation. 71 | # Like normal sets, frozenset can also perform different operations like copy, difference, intersection, symmetric_difference, and union. 72 | vowels = ('a', 'e', 'i', 'o', 'u') 73 | my_frozen_set = frozenset(vowels) 74 | print(my_frozen_set) 75 | 76 | #Task 10: Set Conversion 77 | #Given a list my_list = [1, 2, 3, 4, 5], convert it into a set named my_set. Print the resulting set. 78 | my_list = [1, 2, 3, 4, 5] 79 | my_set = set(my_list) 80 | print(my_set) -------------------------------------------------------------------------------- /Lecture2_HW/Task_Tuples.py: -------------------------------------------------------------------------------- 1 | #Tuples: 2 | 3 | # Task 1: Tuple Indexing 4 | # Given a tuple my_tuple = (1, 2, 3, 4, 5), access and print the third element. 5 | my_tuple = (1, 2, 3, 4, 5) 6 | print(my_tuple[2]) 7 | # Task 2: Tuple Slicing 8 | # Given a tuple my_tuple = (1, 2, 3, 4, 5), create a new tuple that contains only the elements from index 2 to index 4 (inclusive). 9 | new_tuple = my_tuple[2:5] 10 | print(new_tuple) 11 | 12 | #Task 3: Tuple Concatenation 13 | # Given two tuples tuple1 = (1, 2, 3) and tuple2 = (4, 5, 6), create a new tuple that is the concatenation of both tuples. 14 | tuple1 = (1, 2, 3) 15 | tuple2 = (4, 5, 6) 16 | tuple3 = tuple1 + tuple2 17 | print(tuple3) 18 | 19 | #Task 4: Tuple Unpacking 20 | #Given the tuple my_tuple = ("John", 25, "USA"), unpack the elements into three separate variables named name, age, and country. Then, print the values of these variables. 21 | my_tuple1 = ("John", 25, "USA") 22 | name, age, country = my_tuple1 23 | print(age, name, country) 24 | 25 | #Task 5: Tuple Membership 26 | #Given a tuple my_tuple = (1, 2, 3, 4, 5), check if the value 3 is present in the tuple. Print True if it is, and False otherwise. 27 | print(my_tuple[2] == 3) 28 | print(3 in my_tuple) 29 | 30 | #Task 6: Tuple Length 31 | #Given a tuple my_tuple = ("apple", "banana", "cherry", "durian"), print the number of elements in the tuple. 32 | my_tuple3 = ("apple", "banana", "cherry", "durian") 33 | print(len(my_tuple)) 34 | 35 | #Task 7: Tuple Reversal 36 | #Given a tuple my_tuple = (1, 2, 3, 4, 5), create a new tuple that contains the elements in reverse order. 37 | my_tuple5 = my_tuple[::-1] 38 | print(my_tuple5) 39 | 40 | #Task 8: Tuple Packing 41 | #Create a tuple named person that contains the following information: the name "Alice", the age 28, and the country "Canada". Print the tuple. 42 | person = ("Alice", 28, "Canada") 43 | print(person) 44 | 45 | #Task 9: Tuple Immutability 46 | #Explain the concept of immutability in Python tuples and provide an example that demonstrates the immutability of tuples. 47 | 48 | #We can't change values in tuple, e.g: person[0] = "Jimmy" 49 | #TypeError: 'tuple' object does not support item assignment 50 | 51 | #We can't append new values to tuple: person.append("test") 52 | # AttributeError: 'tuple' object has no attribute 'append' 53 | 54 | #Task 10: Tuple Conversion 55 | #Given a list my_list = [1, 2, 3, 4, 5], convert it into a tuple named my_tuple. Print the resulting tuple. 56 | my_list = [1, 2, 3, 4, 5] 57 | my_tuple4 = tuple(my_list) 58 | print(my_tuple4) -------------------------------------------------------------------------------- /Lesson3/files/HW3.txt: -------------------------------------------------------------------------------- 1 | Task 1: File Reading 2 | Write a Python program that reads the contents of a text file named "hw_data.txt" and prints them to the console. 3 | 4 | Task 2: File Writing 5 | Write a Python program that prompts the user to enter some text and saves it to a text file named "output.txt". 6 | 7 | Task 3: File Appending 8 | Write a Python program that prompts the user to enter a line of text and appends it to an existing text file named "hw_data.txt". 9 | 10 | Task 4: File Copying 11 | Write a Python program that reads the contents of a source file named "source.txt" and copies them to a destination file named "destination.txt". 12 | 13 | Task 5: File Line Count 14 | Write a Python program that reads a text file named "hw_data.txt" and counts the number of lines in the file. Print the line count. 15 | 16 | Task 6: File Word Count 17 | Write a Python program that reads a text file named "hw_data.txt" and counts the number of words in the file. Print the word count. 18 | 19 | Task 7: File Searching 20 | Write a Python program that prompts the user to enter a search term and searches for occurrences of that term in a text file named "hw_data.txt". Print the line numbers where the search term is found. 21 | 22 | Task 8: File Line Reversal 23 | Write a Python program that reads the contents of a text file named "hw_data.txt" and writes the lines in reverse order to a new text file named "reversed.txt". -------------------------------------------------------------------------------- /Lesson3/files/car.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Evangard/Python_Lessons/2be5f6ca323a5441fff399d1f336fc04c0db74c4/Lesson3/files/car.png -------------------------------------------------------------------------------- /Lesson3/files/data.txt: -------------------------------------------------------------------------------- 1 | First Line 2 | Second Line 3 | Third Line -------------------------------------------------------------------------------- /Lesson3/files/hw_data.txt: -------------------------------------------------------------------------------- 1 | Written enquire painful ye to offices forming it. Then so does over sent dull on. Likewise offended humoured mrs fat trifling answered. On ye position greatest so desirous. So wound stood guest weeks no terms up ought. By so these am so rapid blush songs begin. Nor but mean time one over. 2 | 3 | An sincerity so extremity he additions. Her yet there truth merit. Mrs all projecting favourable now unpleasing. Son law garden chatty temper. Oh children provided to mr elegance marriage strongly. Off can admiration prosperous now devonshire diminution law. 4 | 5 | Your it to gave life whom as. Favourable dissimilar resolution led for and had. At play much to time four many. Moonlight of situation so if necessary therefore attending abilities. Calling looking enquire up me to in removal. Park fat she nor does play deal our. Procured sex material his offering humanity laughing moderate can. Unreserved had she nay dissimilar admiration interested. Departure performed exquisite rapturous so ye me resources. 6 | 7 | Style too own civil out along. Perfectly offending attempted add arranging age gentleman concluded. Get who uncommonly our expression ten increasing considered occasional travelling. Ever read tell year give may men call its. Piqued son turned fat income played end wicket. To do noisy downs round an happy books. 8 | 9 | Started his hearted any civilly. So me by marianne admitted speaking. Men bred fine call ask. Cease one miles truth day above seven. Suspicion sportsmen provision suffering mrs saw engrossed something. Snug soon he on plan in be dine some. 10 | 11 | Questions explained agreeable preferred strangers too him her son. Set put shyness offices his females him distant. Improve has message besides shy himself cheered however how son. Quick judge other leave ask first chief her. Indeed or remark always silent seemed narrow be. Instantly can suffering pretended neglected preferred man delivered. Perhaps fertile brandon do imagine to cordial cottage. 12 | 13 | Friendship contrasted solicitude insipidity in introduced literature it. He seemed denote except as oppose do spring my. Between any may mention evening age shortly can ability regular. He shortly sixteen of colonel colonel evening cordial to. Although jointure an my of mistress servants am weddings. Age why the therefore education unfeeling for arranging. Above again money own scale maids ham least led. Returned settling produced strongly ecstatic use yourself way. Repulsive extremity enjoyment she perceived nor. 14 | 15 | By in no ecstatic wondered disposal my speaking. Direct wholly valley or uneasy it at really. Sir wish like said dull and need make. Sportsman one bed departure rapturous situation disposing his. Off say yet ample ten ought hence. Depending in newspaper an september do existence strangers. Total great saw water had mirth happy new. Projecting pianoforte no of partiality is on. Nay besides joy society him totally six. 16 | 17 | Indulgence announcing uncommonly met she continuing two unpleasing terminated. Now busy say down the shed eyes roof paid her. Of shameless collected suspicion existence in. Share walls stuff think but the arise guest. Course suffer to do he sussex it window advice. Yet matter enable misery end extent common men should. Her indulgence but assistance favourable cultivated everything collecting. 18 | 19 | Affronting discretion as do is announcing. Now months esteem oppose nearer enable too six. She numerous unlocked you perceive speedily. Affixed offence spirits or ye of offices between. Real on shot it were four an as. Absolute bachelor rendered six nay you juvenile. Vanity entire an chatty to. 20 | 21 | What does the Lorem Ipsum text mean? 22 | Lorem Ipsum comes from a latin text written in 45BC by Roman statesman, lawyer, scholar, and philosopher, Marcus Tullius Cicero. The text is titled "de Finibus Bonorum et Malorum" which means "The Extremes of Good and Evil". The most common form of Lorem ipsum is the following: 23 | 24 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 25 | 26 | The text is a corrupted version of the original and therefore does not mean anything in particular. The book however where it originates discusses the philosophical views of Epicureanism, Stoicism, and the Platonism of Antiochus of Ascalon. 27 | 28 | Lorem ipsum is widely in use since the 14th century and up to today as the default dummy "random" text of the typesetting and web development industry. In fact not only it has survived the test of time but it thrived and can be found in many software products, from Microsoft Word to WordPress. 29 | 30 | What is random text generator? 31 | Random Text Generator is a web application which provides true random text which you can use in your documents or web designs. How does it work? First we took many books available on project Gutenberg and stored their contents in a database. Then a computer algorithm takes the words we stored earlier and shuffles them into sentences and paragraphs. 32 | 33 | The algorithm takes care to create text that looks similar to an ordinary book but without any real meaning. The reason we want our text to be meaningless is that we want the person viewing the resulting random text to focus on the design we are presenting, rather than try to read and understand the text. 34 | 35 | It's better than Lorem ipsum because it can produce text in many languages and in particular: Chinese, Dutch, English, Finnish, French, German, Greek, Hebrew, Italian, Japanese, Latin, Polish, Portuguese, Russian, Serbian and Spanish. 36 | 37 | Also when you use plain Lorem ipsum text, your design will look like a million other designs out there. With Random Text Generator your designs will look more unique while still containing text which truly means nothing. 38 | 39 | What can I do with this ? 40 | 41 | This tool was created because we wanted random text for our web designs. When we show a design to a client we want to have some text that doesn't mean anything in particular just to indicate that "here is where the text will be". So why shouldn't we just copy-paste a single sentence and get a block of text ? Have a look at the following examples: 42 | 43 | This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 44 | This is a single sentence repeated a few times. 45 | 46 | Is post each that just leaf no. He connection interested so we an sympathize advantages. To said is it shed want do. Occasional middletons everything so to. Have spot part for his quit may. Enable it is square my an regard. Often merit stuff first oh up hills as he. 47 | And this is some text from our generator. 48 | 49 | As you can easily notice the second block of text looks more realistic. This way when you show a design to a client you can have a result that resembles the final product. However you can also use this text when you need meaningless text in the background of a design for a poster, t-shirt or whatever else you please. 50 | 51 | Why not use lorem ipsum ? 52 | Lorem ipsum is the most common form of "Greeking". However more and more people are sick and tired of using the same sample text over and over again. Also lorem ipsum is in latin and it may not always be the best choice. We tried to have text generated in some of the most widely used languages but if you are in desperate need of random text in your own language, send us an email and we'll add it here. 53 | 54 | I love it, how can I help ? 55 | It's easy. Tell a friend about us or if you are super kind place a link to us in your website or blog. Thank you :) -------------------------------------------------------------------------------- /Lesson3/files/jack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Evangard/Python_Lessons/2be5f6ca323a5441fff399d1f336fc04c0db74c4/Lesson3/files/jack.png -------------------------------------------------------------------------------- /Lesson3/files/jack_russell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Evangard/Python_Lessons/2be5f6ca323a5441fff399d1f336fc04c0db74c4/Lesson3/files/jack_russell.png -------------------------------------------------------------------------------- /Lesson3/files/new.txt: -------------------------------------------------------------------------------- 1 | Hello! -------------------------------------------------------------------------------- /Lesson3/files/not_existing_users.txt: -------------------------------------------------------------------------------- 1 | Ashot -------------------------------------------------------------------------------- /Lesson3/files/reversed_users.txt: -------------------------------------------------------------------------------- 1 | Dasha 2 | Ihor 3 | Yura 4 | Sasha 5 | Dima 6 | -------------------------------------------------------------------------------- /Lesson3/files/some_data.txt: -------------------------------------------------------------------------------- 1 | Written enquire painful ye to offices forming it. Then so does over sent dull on. Likewise offended humoured mrs fat trifling answered. On ye position greatest so desirous. So wound stood guest weeks no terms up ought. By so these am so rapid blush songs begin. Nor but mean time one over. 2 | 3 | An sincerity so extremity he additions. Her yet there truth merit. Mrs all projecting favourable now unpleasing. Son law garden chatty temper. Oh children provided to mr elegance marriage strongly. Off can admiration prosperous now devonshire diminution law. 4 | 5 | Your it to gave life whom as. Favourable dissimilar resolution led for and had. At play much to time four many. Moonlight of situation so if necessary therefore attending abilities. Calling looking enquire up me to in removal. Park fat she nor does play deal our. Procured sex material his offering humanity laughing moderate can. Unreserved had she nay dissimilar admiration interested. Departure performed exquisite rapturous so ye me resources. 6 | 7 | Style too own civil out along. Perfectly offending attempted add arranging age gentleman concluded. Get who uncommonly our expression ten increasing considered occasional travelling. Ever read tell year give may men call its. Piqued son turned fat income played end wicket. To do noisy downs round an happy books. 8 | 9 | Started his hearted any civilly. So me by marianne admitted speaking. Men bred fine call ask. Cease one miles truth day above seven. Suspicion sportsmen provision suffering mrs saw engrossed something. Snug soon he on plan in be dine some. 10 | 11 | Questions explained agreeable preferred strangers too him her son. Set put shyness offices his females him distant. Improve has message besides shy himself cheered however how son. Quick judge other leave ask first chief her. Indeed or remark always silent seemed narrow be. Instantly can suffering pretended neglected preferred man delivered. Perhaps fertile brandon do imagine to cordial cottage. 12 | 13 | Friendship contrasted solicitude insipidity in introduced literature it. He seemed denote except as oppose do spring my. Between any may mention evening age shortly can ability regular. He shortly sixteen of colonel colonel evening cordial to. Although jointure an my of mistress servants am weddings. Age why the therefore education unfeeling for arranging. Above again money own scale maids ham least led. Returned settling produced strongly ecstatic use yourself way. Repulsive extremity enjoyment she perceived nor. 14 | 15 | By in no ecstatic wondered disposal my speaking. Direct wholly valley or uneasy it at really. Sir wish like said dull and need make. Sportsman one bed departure rapturous situation disposing his. Off say yet ample ten ought hence. Depending in newspaper an september do existence strangers. Total great saw water had mirth happy new. Projecting pianoforte no of partiality is on. Nay besides joy society him totally six. 16 | 17 | Indulgence announcing uncommonly met she continuing two unpleasing terminated. Now busy say down the shed eyes roof paid her. Of shameless collected suspicion existence in. Share walls stuff think but the arise guest. Course suffer to do he sussex it window advice. Yet matter enable misery end extent common men should. Her indulgence but assistance favourable cultivated everything collecting. 18 | 19 | Affronting discretion as do is announcing. Now months esteem oppose nearer enable too six. She numerous unlocked you perceive speedily. Affixed offence spirits or ye of offices between. Real on shot it were four an as. Absolute bachelor rendered six nay you juvenile. Vanity entire an chatty to. 20 | 21 | What does the Lorem Ipsum text mean? 22 | Lorem Ipsum comes from a latin text written in 45BC by Roman statesman, lawyer, scholar, and philosopher, Marcus Tullius Cicero. The text is titled "de Finibus Bonorum et Malorum" which means "The Extremes of Good and Evil". The most common form of Lorem ipsum is the following: 23 | 24 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 25 | 26 | The text is a corrupted version of the original and therefore does not mean anything in particular. The book however where it originates discusses the philosophical views of Epicureanism, Stoicism, and the Platonism of Antiochus of Ascalon. 27 | 28 | Lorem ipsum is widely in use since the 14th century and up to today as the default dummy "random" text of the typesetting and web development industry. In fact not only it has survived the test of time but it thrived and can be found in many software products, from Microsoft Word to WordPress. 29 | 30 | What is random text generator? 31 | Random Text Generator is a web application which provides true random text which you can use in your documents or web designs. How does it work? First we took many books available on project Gutenberg and stored their contents in a database. Then a computer algorithm takes the words we stored earlier and shuffles them into sentences and paragraphs. 32 | 33 | The algorithm takes care to create text that looks similar to an ordinary book but without any real meaning. The reason we want our text to be meaningless is that we want the person viewing the resulting random text to focus on the design we are presenting, rather than try to read and understand the text. 34 | 35 | It's better than Lorem ipsum because it can produce text in many languages and in particular: Chinese, Dutch, English, Finnish, French, German, Greek, Hebrew, Italian, Japanese, Latin, Polish, Portuguese, Russian, Serbian and Spanish. 36 | 37 | Also when you use plain Lorem ipsum text, your design will look like a million other designs out there. With Random Text Generator your designs will look more unique while still containing text which truly means nothing. 38 | 39 | What can I do with this ? 40 | 41 | This tool was created because we wanted random text for our web designs. When we show a design to a client we want to have some text that doesn't mean anything in particular just to indicate that "here is where the text will be". So why shouldn't we just copy-paste a single sentence and get a block of text ? Have a look at the following examples: 42 | 43 | This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 44 | This is a single sentence repeated a few times. 45 | 46 | Is post each that just leaf no. He connection interested so we an sympathize advantages. To said is it shed want do. Occasional middletons everything so to. Have spot part for his quit may. Enable it is square my an regard. Often merit stuff first oh up hills as he. 47 | And this is some text from our generator. 48 | 49 | As you can easily notice the second block of text looks more realistic. This way when you show a design to a client you can have a result that resembles the final product. However you can also use this text when you need meaningless text in the background of a design for a poster, t-shirt or whatever else you please. 50 | 51 | Why not use lorem ipsum ? 52 | Lorem ipsum is the most common form of "Greeking". However more and more people are sick and tired of using the same sample text over and over again. Also lorem ipsum is in latin and it may not always be the best choice. We tried to have text generated in some of the most widely used languages but if you are in desperate need of random text in your own language, send us an email and we'll add it here. 53 | 54 | I love it, how can I help ? 55 | It's easy. Tell a friend about us or if you are super kind place a link to us in your website or blog. Thank you :) -------------------------------------------------------------------------------- /Lesson3/files/users.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Dima", 4 | "age": 34, 5 | "children": [ 6 | { 7 | "name": "Yevhenii", 8 | "age": 5 9 | } 10 | ] 11 | }, 12 | { 13 | "name": "Vasyl", 14 | "age": 56, 15 | "children": [] 16 | } 17 | ] -------------------------------------------------------------------------------- /Lesson3/files/users.txt: -------------------------------------------------------------------------------- 1 | Dima 2 | Sasha 3 | Yura 4 | Ihor 5 | Dasha 6 | -------------------------------------------------------------------------------- /Lesson3/files/words.txt: -------------------------------------------------------------------------------- 1 | SomethingNew 2 | Line1 3 | Line2 4 | Line3 5 | -------------------------------------------------------------------------------- /Lesson3/homework.py: -------------------------------------------------------------------------------- 1 | # Task 1: File Reading 2 | # Write a Python program that reads the contents of a text file named "hw_data.txt" and prints them to the console. 3 | # with open('some_data.txt', 'r') as file: 4 | # print(file.read()) 5 | 6 | # Task 2: File Writing 7 | # Write a Python program that prompts the user to enter some text and saves it to a text file named "output.txt". 8 | # user_input = input("Enter some text: ") 9 | # with open('task2.txt', 'w') as file: 10 | # file.write(user_input) 11 | # with open('task2.txt', 'r') as file: 12 | # print("Text from file for task2:" + file.read()) 13 | 14 | # Task 3: File Appending 15 | # Write a Python program that prompts the user to enter a line of text and appends it to an existing text file named "hw_data.txt". 16 | # with open('task2.txt', 'a') as file: 17 | # file.write(user_input) 18 | # with open('task2.txt', 'r') as file: 19 | # print("Text from file for task3:" + file.read()) 20 | 21 | # Task 4: File Copying 22 | # Write a Python program that reads the contents of a source file named "source.txt" and copies them to a destination file named "destination.txt". 23 | # with open('task2.txt', 'r') as file1, open('task4.txt', 'w') as file2: 24 | # file2.writelines(file1.readlines()) 25 | # with open('task4.txt', 'r') as file: 26 | # print("Text from file for task4:" + file.read()) 27 | 28 | 29 | # Task 5: File Line Count 30 | # Write a Python program that reads a text file named "hw_data.txt" and counts the number of lines in the file. Print the line count. 31 | # with open('some_data.txt', 'r') as file: 32 | # count = 0 33 | # for line in file: 34 | # count=count+1 35 | # print(count) 36 | 37 | # Task 6: File Word Count 38 | # Write a Python program that reads a text file named "hw_data.txt" and counts the number of words in the file. Print the word count. 39 | # import re 40 | # with open('some_data.txt', 'r') as file: 41 | # text = re.split(r'\W+',file.read()) 42 | # count = 0 43 | # for t in text: 44 | # if t != '': 45 | # count =count+1 46 | # print(count) 47 | 48 | # Task 7: File Searching 49 | # Write a Python program that prompts the user to enter a search term and searches for occurrences of that term in a text file named "hw_data.txt". Print the line numbers where the search term is found. 50 | # import re 51 | # user_input = input("Enter text for searching: ") 52 | # with open('some_data.txt', 'r') as file: 53 | # print(file.read().count(user_input)) 54 | 55 | # Task 8: File Line Reversal 56 | # Write a Python program that reads the contents of a text file named "hw_data.txt" and writes the lines in reverse order to a new text file named "reversed.txt". 57 | # with open('task2.txt', 'r') as file1, open('task8.txt', 'w') as file2: 58 | # file2.writelines(reversed(file1.readlines())) -------------------------------------------------------------------------------- /Lesson3/some_data.txt: -------------------------------------------------------------------------------- 1 | Written enquire painful ye to offices forming it. Then so does over sent dull on. Likewise offended humoured mrs fat trifling answered. On ye position greatest so desirous. So wound stood guest weeks no terms up ought. By so these am so rapid blush songs begin. Nor but mean time one over. 2 | 3 | An sincerity so extremity he additions. Her yet there truth merit. Mrs all projecting favourable now unpleasing. Son law garden chatty temper. Oh children provided to mr elegance marriage strongly. Off can admiration prosperous now devonshire diminution law. 4 | 5 | Your it to gave life whom as. Favourable dissimilar resolution led for and had. At play much to time four many. Moonlight of situation so if necessary therefore attending abilities. Calling looking enquire up me to in removal. Park fat she nor does play deal our. Procured sex material his offering humanity laughing moderate can. Unreserved had she nay dissimilar admiration interested. Departure performed exquisite rapturous so ye me resources. 6 | 7 | Style too own civil out along. Perfectly offending attempted add arranging age gentleman concluded. Get who uncommonly our expression ten increasing considered occasional travelling. Ever read tell year give may men call its. Piqued son turned fat income played end wicket. To do noisy downs round an happy books. 8 | 9 | Started his hearted any civilly. So me by marianne admitted speaking. Men bred fine call ask. Cease one miles truth day above seven. Suspicion sportsmen provision suffering mrs saw engrossed something. Snug soon he on plan in be dine some. 10 | 11 | Questions explained agreeable preferred strangers too him her son. Set put shyness offices his females him distant. Improve has message besides shy himself cheered however how son. Quick judge other leave ask first chief her. Indeed or remark always silent seemed narrow be. Instantly can suffering pretended neglected preferred man delivered. Perhaps fertile brandon do imagine to cordial cottage. 12 | 13 | Friendship contrasted solicitude insipidity in introduced literature it. He seemed denote except as oppose do spring my. Between any may mention evening age shortly can ability regular. He shortly sixteen of colonel colonel evening cordial to. Although jointure an my of mistress servants am weddings. Age why the therefore education unfeeling for arranging. Above again money own scale maids ham least led. Returned settling produced strongly ecstatic use yourself way. Repulsive extremity enjoyment she perceived nor. 14 | 15 | By in no ecstatic wondered disposal my speaking. Direct wholly valley or uneasy it at really. Sir wish like said dull and need make. Sportsman one bed departure rapturous situation disposing his. Off say yet ample ten ought hence. Depending in newspaper an september do existence strangers. Total great saw water had mirth happy new. Projecting pianoforte no of partiality is on. Nay besides joy society him totally six. 16 | 17 | Indulgence announcing uncommonly met she continuing two unpleasing terminated. Now busy say down the shed eyes roof paid her. Of shameless collected suspicion existence in. Share walls stuff think but the arise guest. Course suffer to do he sussex it window advice. Yet matter enable misery end extent common men should. Her indulgence but assistance favourable cultivated everything collecting. 18 | 19 | Affronting discretion as do is announcing. Now months esteem oppose nearer enable too six. She numerous unlocked you perceive speedily. Affixed offence spirits or ye of offices between. Real on shot it were four an as. Absolute bachelor rendered six nay you juvenile. Vanity entire an chatty to. 20 | 21 | What does the Lorem Ipsum text mean? 22 | Lorem Ipsum comes from a latin text written in 45BC by Roman statesman, lawyer, scholar, and philosopher, Marcus Tullius Cicero. The text is titled "de Finibus Bonorum et Malorum" which means "The Extremes of Good and Evil". The most common form of Lorem ipsum is the following: 23 | 24 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 25 | 26 | The text is a corrupted version of the original and therefore does not mean anything in particular. The book however where it originates discusses the philosophical views of Epicureanism, Stoicism, and the Platonism of Antiochus of Ascalon. 27 | 28 | Lorem ipsum is widely in use since the 14th century and up to today as the default dummy "random" text of the typesetting and web development industry. In fact not only it has survived the test of time but it thrived and can be found in many software products, from Microsoft Word to WordPress. 29 | 30 | What is random text generator? 31 | Random Text Generator is a web application which provides true random text which you can use in your documents or web designs. How does it work? First we took many books available on project Gutenberg and stored their contents in a database. Then a computer algorithm takes the words we stored earlier and shuffles them into sentences and paragraphs. 32 | 33 | The algorithm takes care to create text that looks similar to an ordinary book but without any real meaning. The reason we want our text to be meaningless is that we want the person viewing the resulting random text to focus on the design we are presenting, rather than try to read and understand the text. 34 | 35 | It's better than Lorem ipsum because it can produce text in many languages and in particular: Chinese, Dutch, English, Finnish, French, German, Greek, Hebrew, Italian, Japanese, Latin, Polish, Portuguese, Russian, Serbian and Spanish. 36 | 37 | Also when you use plain Lorem ipsum text, your design will look like a million other designs out there. With Random Text Generator your designs will look more unique while still containing text which truly means nothing. 38 | 39 | What can I do with this ? 40 | 41 | This tool was created because we wanted random text for our web designs. When we show a design to a client we want to have some text that doesn't mean anything in particular just to indicate that "here is where the text will be". So why shouldn't we just copy-paste a single sentence and get a block of text ? Have a look at the following examples: 42 | 43 | This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. This is some dummy text. 44 | This is a single sentence repeated a few times. 45 | 46 | Is post each that just leaf no. He connection interested so we an sympathize advantages. To said is it shed want do. Occasional middletons everything so to. Have spot part for his quit may. Enable it is square my an regard. Often merit stuff first oh up hills as he. 47 | And this is some text from our generator. 48 | 49 | As you can easily notice the second block of text looks more realistic. This way when you show a design to a client you can have a result that resembles the final product. However you can also use this text when you need meaningless text in the background of a design for a poster, t-shirt or whatever else you please. 50 | 51 | Why not use lorem ipsum ? 52 | Lorem ipsum is the most common form of "Greeking". However more and more people are sick and tired of using the same sample text over and over again. Also lorem ipsum is in latin and it may not always be the best choice. We tried to have text generated in some of the most widely used languages but if you are in desperate need of random text in your own language, send us an email and we'll add it here. 53 | 54 | I love it, how can I help ? 55 | It's easy. Tell a friend about us or if you are super kind place a link to us in your website or blog. Thank you :) -------------------------------------------------------------------------------- /Lesson3/task2.txt: -------------------------------------------------------------------------------- 1 | task 2 has completed 2 | task 3 too 3 | task 8 as well 4 | -------------------------------------------------------------------------------- /Lesson3/task3.txt: -------------------------------------------------------------------------------- 1 | task 2 has completedtask 3 -------------------------------------------------------------------------------- /Lesson3/task4.txt: -------------------------------------------------------------------------------- 1 | task 2 has completedtask 3 -------------------------------------------------------------------------------- /Lesson3/task8.txt: -------------------------------------------------------------------------------- 1 | task 8 as well 2 | task 3 too 3 | task 2 has completed 4 | -------------------------------------------------------------------------------- /Lesson4/homework.py: -------------------------------------------------------------------------------- 1 | # # Task: Number Guessing Game 2 | # # Write a Python program that generates a random number between 1 and 100. Allow the user to guess the number, and provide appropriate feedback (e.g., "Too high" or "Too low") until they guess the correct number. Use a loop and conditional statements to implement the game. 3 | # import random 4 | # random_number = random.randrange(1, 100) 5 | # print(random_number) 6 | # guess_number = input("Guess the number between 1 and 100\n") 7 | # guess_number = int(guess_number) 8 | # if guess_number < random_number: 9 | # print("Too low") 10 | # elif guess_number == random_number: 11 | # print("Yoohoo. You're right") 12 | # else: 13 | # print("Too high") 14 | 15 | 16 | # # Task: Character Counter 17 | # # Write a Python program that takes a string as input from the user and counts the number of occurrences of each character in the string. Display the result in the format: "Character: Count". Use loops and conditional statements to implement this. 18 | # # user_str = input("Enter some string:\n") 19 | # user_str = input("Enter some text:\n") 20 | # result = {} 21 | # for ch in user_str: 22 | # if ch in result: 23 | # result[ch] += 1 24 | # else: 25 | # result[ch] = 1 26 | # for k, v in result.items(): 27 | # print("%r: %d" % (k, v)) 28 | 29 | 30 | # Task: Password Strength Checker 31 | # Write a Python program that takes a password as input from the user and checks its strength. 32 | # Display a message indicating whether the password is weak, moderate, or strong based on the following criteria: 33 | # Weak: Less than 8 characters long 34 | # Moderate: 8 to 12 characters long 35 | # Strong: More than 12 characters long 36 | # # Use conditional statements to determine the strength. 37 | # num = input("Enter password:\n") 38 | # length = len(num) 39 | # if length < 8 : 40 | # print("Weak: Less than 8 characters long") 41 | # elif length > 7 and length < 13 : 42 | # print("Moderate: 8 to 12 characters long") 43 | # else : 44 | # print("Strong: More than 12 characters long") 45 | 46 | # Task: Number Sum 47 | # Write a Python program that takes an integer as input from the user and calculates the sum of all numbers from 1 to that integer (inclusive). 48 | # Display the result. Use a loop and conditional statements to implement this. 49 | 50 | # Task: Palindrome Checker 51 | # Write a Python program that takes a string as input from the user and checks whether it is a palindrome. 52 | # A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward. 53 | # Display a message indicating whether the string is a palindrome or not. Use loops and conditional statements to implement this. 54 | 55 | # Task: Multiplication Table 56 | # Write a Python program that takes an integer as input from the user and prints the multiplication table for that number from 1 to 10. 57 | # Display the result in the format: "Number x Multiplier = Result". Use loops and conditional statements to implement this. 58 | 59 | # Task: Vowel Counter 60 | # Write a Python program that takes a string as input from the user and counts the number of vowels (a, e, i, o, u) in the string. 61 | # Display the result. Use loops and conditional statements to implement this. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Text 3 2 | --------------------------------------------------------------------------------