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

Diff for: Book Entry/bookEntrirer.py

+10
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()

Diff for: Calculate the number of books/javaBooksCalculator.py

+7
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")

Diff for: Vowel Counter from file/codeReader.md

+37
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+
___

Diff for: book.txt

+3
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

Diff for: books.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1.HeadFirst Java,American
2+
1.2,ewf

Diff for: employeeWithHighestSalary.py

-9
This file was deleted.

Diff for: employees.txt

-4
This file was deleted.

0 commit comments

Comments
 (0)