Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Employee #82

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
14 changes: 14 additions & 0 deletions Desktop/Majd Readme/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Python File",
"type": "debugpy",
"request": "launch",
"program": "${file}"
}
]
}
1 change: 1 addition & 0 deletions Desktop/Majd Readme/ET6-foundations-group-16
Submodule ET6-foundations-group-16 added at 103e93
15 changes: 15 additions & 0 deletions solutions/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
13 changes: 13 additions & 0 deletions solutions/Countvowels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def count_vowels_recursively(string):
if not string:
return 0
else:
if string[0].lower() in "aeiou":
return 1 + count_vowels_recursively(string[1:])
else:
return count_vowels_recursively(string[1:])


input_string = "Palestinian culture is beautiful."
a = count_vowels_recursively(input_string)
print(f"Number of vowels in '{input_string}' is: {a}")
1 change: 1 addition & 0 deletions solutions/ET6-foundations-group-16
Submodule ET6-foundations-group-16 added at 99711b
15 changes: 15 additions & 0 deletions solutions/Intersection_element.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def common_elements(list1, list2):
# Convert both lists to sets to remove duplicates and find intersection
set1 = set(list1)
set2 = set(list2)
# Find the common elements
common = set1.intersection(set2)
# Convert the result back to a list
return list(common)


# Example usage
list1 = [1, 2, 3, 4, 5, 6, 7]
list2 = [4, 5, 6, 7, 8, 9]
result = common_elements(list1, list2)
print(result) # Output: [4, 5, 6]
1 change: 0 additions & 1 deletion solutions/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

14 changes: 14 additions & 0 deletions solutions/count_vowel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Function that count the vowel in sentence
def count_vowels_recursively(string):
if not string:
return 0
else:
if string[0].lower() in "aeiou":
return 1 + count_vowels_recursively(string[1:])
else:
return count_vowels_recursively(string[1:])


input_string = "Palestinian culture is beautiful."
a = count_vowels_recursively(input_string)
print(f"Number of vowels in '{input_string}' is: {a}")
14 changes: 14 additions & 0 deletions solutions/employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Employee:
raise_amt =1.05
def __init__(self,first,last,pay):
self.first=first
self.last=last
self.pay=pay

def email(self):
return f'{self.first}.{self.last}@email.com'
def fullname(self):
return f'{self.first}.{self.last}'
def apply_raise(self):
self.pay=int(self.pay*self.raise_amt)

15 changes: 15 additions & 0 deletions solutions/intersection_element.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def common_elements(list1, list2):
# Convert both lists to sets to remove duplicates and find intersection
set1 = set(list1)
set2 = set(list2)
# Find the common elements
common = set1.intersection(set2)
# Convert the result back to a list
return list(common)


# Example usage
list1 = [1, 2, 3, 4, 5, 6, 7]
list2 = [4, 5, 6, 7, 8, 9]
result = common_elements(list1, list2)
print(result) # Output: [4, 5, 6]
51 changes: 51 additions & 0 deletions solutions/tests/Test_countvowel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Test cases for the function count_vowels_recursively
def test_count_vowels_recursively():
# Test case 1: Empty string
assert (
count_vowels_recursivelycount_vowels_recursively("") == 0

Check failure on line 5 in solutions/tests/Test_countvowel.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F821)

solutions/tests/Test_countvowel.py:5:9: F821 Undefined name `count_vowels_recursivelycount_vowels_recursively`
), "Test case 1 failed" # type: ignore

# Test case 2: String with no vowels
assert (
count_vowels_recursivelycount_vowels_recursively("bcdfghjklmnpqrstvwxyz") == 0

Check failure on line 10 in solutions/tests/Test_countvowel.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F821)

solutions/tests/Test_countvowel.py:10:9: F821 Undefined name `count_vowels_recursivelycount_vowels_recursively`
), "Test case 2 failed" # type: ignore

# Test case 3: String with only vowels
assert (
count_vowels_recursivelycount_vowels_recursively("aeiouAEIOU") == 10

Check failure on line 15 in solutions/tests/Test_countvowel.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F821)

solutions/tests/Test_countvowel.py:15:9: F821 Undefined name `count_vowels_recursivelycount_vowels_recursively`
), "Test case 3 failed" # type: ignore

# Test case 4: Mixed string
assert (
count_vowels_recursivelycount_vowels_recursively("hello world,") == 3

Check failure on line 20 in solutions/tests/Test_countvowel.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F821)

solutions/tests/Test_countvowel.py:20:9: F821 Undefined name `count_vowels_recursivelycount_vowels_recursively`
), "Test case 4 failed" # type: ignore

# Test case 5: Complex sentence
assert (
count_vowels_recursivelycount_vowels_recursively(

Check failure on line 25 in solutions/tests/Test_countvowel.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F821)

solutions/tests/Test_countvowel.py:25:9: F821 Undefined name `count_vowels_recursivelycount_vowels_recursively`
"The quick brown fox jumps over the lazy dog"
)
== 11
), "Test case 5 failed" # type: ignore

# Test case 6: String with special characters and spaces
assert (
count_vowels_recursivelycount_vowels_recursively("!@#$%^&*()_+ 1234567890-=")

Check failure on line 33 in solutions/tests/Test_countvowel.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F821)

solutions/tests/Test_countvowel.py:33:9: F821 Undefined name `count_vowels_recursivelycount_vowels_recursively`
== 0
), "Test case 6 failed" # type: ignore

# Test case 7: Single character (vowel)
assert (
count_vowels_recursivelycount_vowels_recursively("a") == 1

Check failure on line 39 in solutions/tests/Test_countvowel.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F821)

solutions/tests/Test_countvowel.py:39:9: F821 Undefined name `count_vowels_recursivelycount_vowels_recursively`
), "Test case 7 failed" # type: ignore

# Test case 8: Single character (non-vowel)
assert (
count_vowels_recursivelycount_vowels_recursively("b") == 0

Check failure on line 44 in solutions/tests/Test_countvowel.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F821)

solutions/tests/Test_countvowel.py:44:9: F821 Undefined name `count_vowels_recursivelycount_vowels_recursively`
), "Test case 8 failed" # type: ignore

print("All test cases passed!")


# Run the tests
test_count_vowels_recursively()
189 changes: 189 additions & 0 deletions solutions/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,190 @@
from math import sqrt

# Write a function that takes a sentence and returns the longest word in that sentence
s = "I am learning Python programming language"

# Split the sentence into words
words = s.split()

# Initialize an empty string to store the longest word
res = ""

# Iterate through each word
for word in words:
# Update 'res' if the current word is longer than 'res'
if len(word) > len(res):
res = word

print(res)

# Longest word

# Reading sentence from user

sentence = input("Enter sentence: ")

# Finding longest word
longest = max(sentence.split(), key=len)

# Displaying longest word
print("Longest word is: ", longest)
print("And its length is: ", len(longest))


# Function to check the Vowel
def isVowel(ch):
return ch.upper() in ["A", "E", "I", "O", "U"]


# to count total number of
# vowel from 0 to n
def countVovels(str, n):
if n == 1:
return isVowel(str[n - 1])

return countVovels(str, n - 1) + isVowel(str[n - 1])


# Driver Code

# string object
str = "abc de"
# Total numbers of Vowel
print(countVovels(str, len(str)))


def count_vowels_recursively(string):
if not string:
return 0
else:
if string[0].lower() in "aeiou":
return 1 + count_vowels_recursively(string[1:])
else:
return count_vowels_recursively(string[1:])


input_string = "Palestinian culture is beautiful."
a = count_vowels_recursively(input_string)
print(f"Number of vowels in '{input_string}' is: {a}")

# Different Sizes using Sorting


def medianOf2(a, b):
# Merge both the arrays
c = a + b

# Sort the concatenated array
c.sort()

len_c = len(c)

# If length of array is even
if len_c % 2 == 0:
return (c[len_c // 2] + c[len_c // 2 - 1]) / 2.0

# If length of array is odd
else:
return c[len_c // 2]


if __name__ == "__main__":
a = [-5, 3, 6, 12, 15, 44]
b = [-12, -10, -6, -3, 21, 10]

print(medianOf2(a, b))

# write a code that return a list of the elements that are common to both lists, without duplicates.
a = [1, 2, 3, 4, 5]
b = [4, 5, 6, 7, 8]

# Find common elements using nested loops
common = []
for x in a:
if x in b:
common.append(x)

print(common)


# Given a positive integer, determine if it is a prime number
# (a number greater than 1 that has no divisors other than 1
# and itself).
# prime function to check given number prime or not
def Prime(number, itr):
# base condition
if itr == 1 or itr == 2:
return True
# if given number divided by itr or not
if number % itr == 0:
return False
# Recursive function Call
if Prime(number, itr - 1) == False:

Check failure on line 122 in solutions/tests/__init__.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (E712)

solutions/tests/__init__.py:122:8: E712 Avoid equality comparisons to `False`; use `if not Prime(number, itr - 1):` for false checks
return False

return True


num = 14

itr = int(sqrt(num) + 1)

print(Prime(num, itr))

# Python program to find the factorial of a number provided by the user.

# change the value for a different result
num = 6

# To take input from the user
# num = int(input("Enter a number: "))

factorial = 1

# check if the number is negative, positive or zero
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1, num + 1):
factorial = factorial * i
print("The factorial of", num, "is", factorial)

# Python program to find the factorial of a number provided by the user
# using recursion


def factorial(x):
"""This is a recursive function
to find the factorial of an integer"""

if x == 1 or x == 0:
return 1
else:
# recursive call to the function
return x * factorial(x - 1)


# change the value for a different result
num = 8

# to take input from the user
# num = int(input("Enter a number: "))

# call the factorial function
result = factorial(num)
print("The factorial of", num, "is", result)


# Python program to illustrate the intersection
# of two lists in most simple way
def intersection(lst1, lst2):
lst3 = [value for value in lst1 if value in lst2]
return lst3


# Driver Code
lst1 = [4, 9, 1, 17, 11, 26, 28, 54, 69]
lst2 = [9, 9, 74, 21, 45, 11, 63, 28, 26]
print(intersection(lst1, lst2))
Loading
Loading