Skip to content
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
62 changes: 62 additions & 0 deletions Day 2/variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Day 2: 30 Days of python programming
# ! Level 1
first_name = "Ahmad"
last_name = "Al-Sanosi"
full_name = first_name + " " + last_name
country = "Sudan"
city = "Khartoum"
age = 21
year = 2003
is_married = False
is_true = True
is_light_on = False
street_num, building_num, room_num = 4, 21, 623

# ! Level 2
print(f"The data type of {first_name} is {type(first_name)}")
print(f"The data type of {last_name} is {type(last_name)}")
print(f"The data type of {full_name} is {type(full_name)}")
print(f"The data type of {country} is {type(country)}")
print(f"The data type of {city} is {type(city)}")
print(f"The data type of {age} is {type(age)}")
print(f"The data type of {year} is {type(year)}")
print(f"The data type of {is_married} is {type(is_married)}")
print(f"The data type of {is_light_on} is {type(is_light_on)}")
print(f"The data type of {street_num} is {type(street_num)}")
print(f"The data type of {building_num} is {type(building_num)}")
print(f"The data type of {room_num} is {type(room_num)}")

print(f"The length of {first_name} is {len(first_name)} while the length of the {last_name} is {len(last_name)}")

num_one = 5
num_two = 4
total = num_one + num_two
diff = num_one - num_two
product = num_one * num_two
division = num_one / num_two
remainder = num_two % num_one
exp = num_one ** num_two
floor_division = num_one // num_two
print(f"we have two numbers {num_one} and {num_two}")
print(f"The sum of {num_one} plus {num_two} equals {total}")
print(f"The difference of {num_one} minus {num_two} equals {diff}")
print(f"The product of {num_one} times {num_two} equals {product}")
print(f"The quotient of {num_one} over {num_two} equals {division}")
print(f"The remainder when dividing {num_two} by {num_one} is {remainder}")
print(f"The product of raising {num_one} to the power of {num_two} equals {exp}")
print(f"The floor division of {num_one} by {num_two} equals {floor_division}")

radius_string = input('Enter a radius of a circle: ')
radius = int(radius_string)
area_of_circle = 3.14 * (radius ** 2)
circum_of_circle = 2 * 3.14 * radius
print(f"""The area of a circle of radius {radius} meters is equal to {area_of_circle}
and the circumference of that circle equals {circum_of_circle}""")

first_name = input('Enter your first name :')
last_name = input('Enter your last name :')
country = input('Enter your country :')
age = input('Enter your age :')



94 changes: 94 additions & 0 deletions Day 3/Day 3 Exercises.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
your_age = 28
your_height = 191.5
imaginary = 32 + 4j
print(f"type of your_age is {type(your_age)}")
print('type of your_height is', type(your_height))

##################################################

script_base = input('Enter the base of a triangle: ')
base = float(script_base)
script_height = input('Enter the height of that triangle: ')
height = float(script_height)
print(f"The area of the triangle equals {round(0.5 * base * height, 2)}")

side_a = input('Enter side a of a triangle: ')
a = float(side_a)
side_b = input('Enter side b of a triangle: ')
b = float(side_b)
side_c = input('Enter side c of a triangle: ')
c = float(side_c)
print('The perimeter of the triangle is ', a + b + c)

script_length = input('Enter the length of a rectangle: '); length = float(script_length)
script_width = input('Enter the width of that rectangle: '); width = float(script_width)
print(f"The area of the rectangle equals {round(length * width, 2)}, and the perimeter of that rectangle equals {round(2*(length + width), 2)}")

script_radius = input('Enter the radius of a circle: ')
radius = float(script_radius)
print('The area of the circle equals ', round(3.14 * radius**2, 2), ', and the circumference of that circle equals ', round(2*3.14*radius, 2))

#####################################################

script_slope = input('Enter the value of the slope of a line:' ); slope = int(script_slope)
script_b = input('Enter the value of the free term of the line (If none, enter 0): '); b = int(script_b)
print(f"The equation of the line you entered is y = {slope}x + ({b})")
print(f"The slope of the equation equals {slope}. The x-intercept equals {-(b)/slope} and the y-intercept equals {b}")

#####################################################

print("Let's point out two points on the x-y plane!")
script_x1 = input('Enter the x-coordinate of the first point: '); x1 = int(script_x1)
script_y1 = input('Enter the y-coordinate of the first point: '); y1 = int(script_y1)
script_x2 = input('Enter the x-coordinate of the second point: '); x2 = int(script_x2)
script_y2 = input('Enter the y-coordinate of the second point: '); y2 = int(script_y2)
slope2 = round((y2-y1)/(x2-x1),2)
print(f"You've just entered the line equation: ({slope2})x + ({round((y1 - slope2*x1),2)})")
print(f"The euclidean distance between the points ({x1},{y1}) and ({x2},{y2}) equals {round(((y2-y1)**2+(x2-x1)**2)**0.5,2)}")

########################################################

print('I challenge you to solve this problem.\n Find the x value that makes this equation equals 0 (You have only one trial)')
print('y = x^2 + 6x + 9')
script_user_answer = input('Enter your value for x in integers only: '); user_answer = int(script_user_answer)
if user_answer == -3 : print('Congratulations! Your answer is correct.')
else : print('Sorry. That was incorrect :/')

#########################################################

print('python is longer than dragon is a ', len('python') > len('dragon'), 'statement.')
print(f"The 'on' word exists on both python and dragon is a {'on' in 'python' and 'on' in 'dragon'} statement.")
print(f"there's jargon in 'I hope this course is not full of jargon' is a {'jargon' in 'I hope this course is not full of jargon'} statement.")
print(f"There's no 'on' in both dragon and python is a {'on' not in 'dragon' and 'on' not in 'python'} statement.")
print(f"The length of the word 'python' equals {len('python')}: {float(len('python'))}: {str(len('python'))}")

##########################################################

string_number = input("Enter an integer and I'll tell it's even or odd: "); number = int(string_number)
if number % 2 == 0 : print('Number is even')
else : print('Number is odd')

##########################################################

print(f"'The floor division of 7 by 3 is equal to the int converted value of 2.7' is a {7 // 3 == int(2.7)} statement.")
print(f"The type of '10' is equal to type of 10 is a {'10' is 10} statement.")
print(f"int('9.8') is equal to 10 is a {int(9.8) == 10} statement.")

##########################################################

string_hours = input('Enter the number of hours: '); hours = int(string_hours)
string_rph = input('Enter the rate per hour: '); rph = int(string_rph)
print(f"Your weekly earning is about {hours * rph}")

##########################################################

age = int(input('Enter your age: '))
print('You have lived for ', age * 365 * 24 * 60 * 60, 'seconds.')

##########################################################

print('1 1 1 1 1 \n2 1 2 4 8 \n3 1 3 9 27 \n4 1 4 16 64 \n5 1 5 25 125 ')




143 changes: 143 additions & 0 deletions Day 4/Day 4 Exercises.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#1
Thirty = 'Thirty'
Days = 'Days'
Of = 'of'
Python = 'Python'
print(Thirty + ' ' + Days + ' ' + Of + ' ' + Python)

#2
Coding = 'Coding'
_For = ' For'
All = ' All'
print(Coding + _For + All)

#3, 4, 5, 6, 7, 8, 9
company = 'Coding For All'
print(company)
print(f"length of Coding For All is {len(company)}")
print(company.upper())
print(company.lower())
print(f"""
Preview of several methods and their effects:
.capitalize() > {company.capitalize()}
.title() > {company.title()}
.swapcase() > {company.swapcase()}
""")
company_first_word = company[0:6]
print(f"First word of {company} is ({company_first_word})")

#10
company_check = company.find('Coding') != -1
company_ans = f'"{company} contains the word {company_first_word}" is a {company_check} statement.'
company_ans_lowercase = company_ans.lower()
print(company_ans_lowercase)

#11
company_replace = company.replace('Coding', 'Python')
print(company_replace)

#12
python_all = 'Python For Everyone'
print(python_all.replace('Everyone', 'All'))

#13
company_split = company.split('*')
print(company_split)

#14
brands = "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon"
brands_split = brands.split(', ')
print(brands_split)

#15
print(f"The character at index 0 in the string '{company}' is '{company[0:1]}'")

#16
print(f'The last index of the string "{company}" is {company.rfind('l')}')

#17
print(f"The character at index 10 in '{company}' is '{company[10:11]}'")

#18
company_acronym1 = company[0:1]
company_acronym2 = company[7:8]
company_acronym3 = company[11:12]
print(company_acronym1+company_acronym2+company_acronym3)

#19
python_all_acronym1 = python_all[0:1]
python_all_acronym2 = python_all[7:8]
python_all_acronym3 = python_all[11:12]
print(python_all_acronym1+python_all_acronym2+python_all_acronym3)

#20
print(f'The index of the first occurence of C in {company} is {company.index('C')}')

#21
print(f'The index of the first occurence of F in {company} is {company.index('F')}')

#22
people = 'Coding For All People'
print(f'The index of the last occurence of l in {people} is {people.rfind('l')}')

#23
conjuction = 'You cannot end a sentence with because because because is a conjunction'
print(f'The index of the first occurence of "because" in "{conjuction}" is {conjuction.find('because')}')

#24
print(f'The index of the last occurence of "because" in "{conjuction}" is {conjuction.rindex('because')}')

#25
#? conjuction_sliced = conjuction[31:54]
#? print(conjuction_sliced)
#! TO AMMAR: Do I need to put everything into a variable?
print(conjuction[31:54])

#26
print(f'The index of the first occurence of "because" in "{conjuction}" is {conjuction.find('because')}')

#27
print(conjuction[31:54])

#28
coding_start = company.startswith('Coding')
coding_end = company.endswith('Coding')
print(company)
print(f'"{company} starts with the word {company_first_word}" is a {str(coding_start).lower()} statement.')

#29
print(f'"{company} ends with the word {company_first_word}" is a {str(coding_end).lower()} statement.')

#30
company_space = ' Coding For All '
company_space_stripped = company_space.strip(' ')
print(company_space_stripped)

#31
isidentifier1 = '30DaysOfPython'
isidentifier2 = 'thirty_days_of_python'
print(f'"{isidentifier1} is a {str(isidentifier1).isidentifier()} identifier.')
print(f'"{isidentifier1} is a {str(isidentifier2).isidentifier()} identifier.')

#32
list1 = ['Django', 'Flask', 'Bottle', 'Pyramid', 'Falcon']
print('# '.join(list1))

#33
escape = 'I am enjoying this challenge. I just wonder what is next.'
# 0123456789
escape_slice1 = escape[0:29]
escape_slice2 = escape[30:]
print(escape_slice1 + '\n' + escape_slice2)

#34
print('Name\t\tAge\t\tCountry\t\tCity')
print('Asabeneh\t250\t\tFinland\t\tHelsinki')

#35
radius = 10
area = 3.14 * radius ** 2
print('The area of a circle with radius {} is {} meters square.'.format(radius, area))

#36
print('8 + 6 = {}\n8 - 6 = {}\n8 * 6 = {}\n8 / 6 = {}\n8 % 6 = {}\n8 // 6 = {}\n8 ** 6 = {}'.format(8+6, 8-6, 8*6, round(8/6, 1), 8%6, 8//6, 8**6))
34 changes: 34 additions & 0 deletions Day 4/Day 4 Notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

```py
sentence = "A\tB"
print(sentence)
print(len(sentence))
expanded_tab = sentence.expandtabs(8)
print(expanded_tab)
```


> [!NOTE] Note about .expandtabs( )
> number in parents( ) will be executed with a value less than it by one


```py
name = input("Enter your name")
if name.isalpha():
print("Thanks")
else:
print('invalid')
```

___

```py
#* Join

name = "Ahmed Ammar Sanosi"
#* 01234567890
#* 0 1 2

# []
```
![[Pasted image 20250705091203.png]]
Binary file added Day 4/Note1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Day 4/Pasted image 20250705091203.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading