Skip to content

Commit 840783e

Browse files
committed
29th April class Remove employeeWithHighestSalary.py and employees.txt
1 parent 4cc310c commit 840783e

File tree

7 files changed

+59
-13
lines changed

7 files changed

+59
-13
lines changed

Book Entry/bookEntrirer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
myfile = open("books.txt", "a")
2+
ans = 'y'
3+
while ans =='y':
4+
bno = int(input("Enter book no"))
5+
bname = input("Enter book name")
6+
author = input("Enter Author Name")
7+
brec = str(bno) + "." + bname + "," + author +"\n"
8+
myfile.write(brec)
9+
ans = input("Add More?")
10+
myfile.close()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
myfile = open("books.txt", "r")
2+
count = 0
3+
for line in myfile:
4+
if "Java" in line:
5+
count += 1
6+
myfile.close()
7+
print("There are", count, "books for Java")

Vowel Counter from file/codeReader.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Summary
2+
This code snippet reads the contents of a file named "employees.txt" and counts the number of vowels in the file.
3+
4+
## Example Usage
5+
```python
6+
# employees.txt file contains the following text:
7+
# John Doe
8+
# Jane Smith
9+
# Alex Johnson
10+
11+
f = open("employees.txt", "r")
12+
contents = f.read()
13+
vowels = 'aeiouAEIOU'
14+
count = 0
15+
for letter in contents:
16+
if letter in vowels:
17+
count += 1
18+
print("Number of vowels: ", count)
19+
```
20+
21+
## Code Analysis
22+
### Inputs
23+
- The code snippet requires a file named "employees.txt" to be present in the same directory.
24+
- The file should contain text.
25+
___
26+
### Flow
27+
1. The code snippet opens the file "employees.txt" in read mode.
28+
2. It reads the entire contents of the file and stores it in the variable `contents`.
29+
3. It initializes a variable `vowels` with all the vowels in lowercase and uppercase.
30+
4. It initializes a variable `count` to keep track of the number of vowels.
31+
5. It iterates over each character in the `contents` string.
32+
6. If the character is a vowel (present in the `vowels` string), it increments the `count` variable.
33+
7. Finally, it prints the total number of vowels found in the file.
34+
___
35+
### Outputs
36+
- The code snippet outputs the total number of vowels found in the file.
37+
___

book.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.HeadFirst Java,American
2+
2.Java,OOPS for java
3+
1. HeadFirst Java,American

books.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1.HeadFirst Java,American
2+
1.2,ewf

employeeWithHighestSalary.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

employees.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)