Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e70d188
Create zahid_team_leader_week1.py
zahidulsilam Apr 7, 2025
aa136fa
Update zahid_team_leader_week1.py
zahidulsilam Apr 7, 2025
22302e0
Create Week_1_Answers.py
Asem-Altaweel Apr 10, 2025
3bc6bc8
Add files via upload
Asem-Altaweel Apr 10, 2025
f4a5d51
Merge branch 'Zahid-team-leader'
Asem-Altaweel Apr 10, 2025
29663f2
Questions 1 t0 9 are done
Asem-Altaweel Apr 10, 2025
1d4a23b
Merge branch 'main' of https://github.com/zahidulsilam/Python_Modul_W…
Asem-Altaweel Apr 10, 2025
e114d3c
Week one Ansers from Asem is Completed
Asem-Altaweel Apr 11, 2025
7e8e776
All Question are fixed
zahidulsilam Apr 11, 2025
733cfd3
branch rename and question 1 Done
zahidulsilam Apr 11, 2025
f7ff459
Merge pull request #1 from zahidulsilam/Zahid-team-leader
zahidulsilam Apr 11, 2025
d59cbfb
Zahid team leader question2
zahidulsilam Apr 11, 2025
402b065
Merge pull request #2 from zahidulsilam/zahid-team-leader_question2
zahidulsilam Apr 11, 2025
f03a270
Zahid team leader question3
zahidulsilam Apr 11, 2025
ec9c5b0
Merge pull request #3 from zahidulsilam/zahid-team-leader_question3
zahidulsilam Apr 11, 2025
5482d59
Zahid team leader question4
zahidulsilam Apr 11, 2025
690af9a
Merge pull request #4 from zahidulsilam/zahid-team-leader_question4
zahidulsilam Apr 11, 2025
5218967
Zahid team leader question6
zahidulsilam Apr 11, 2025
0ec31e7
Merge pull request #5 from zahidulsilam/zahid-team-leader_question5
zahidulsilam Apr 11, 2025
a81bc02
Zahid team leader question6
zahidulsilam Apr 11, 2025
2c8d5a1
Merge pull request #6 from zahidulsilam/zahid-team-leader_question6
zahidulsilam Apr 11, 2025
ec22d63
Zahid team leader question7
zahidulsilam Apr 11, 2025
7165794
Merge pull request #7 from zahidulsilam/zahid-team-leader_question7
zahidulsilam Apr 11, 2025
b019eea
Zahid team leader question8
zahidulsilam Apr 11, 2025
92e74e4
Merge pull request #8 from zahidulsilam/zahid-team-leader_question8
zahidulsilam Apr 11, 2025
440f429
Zahid team leader question9
zahidulsilam Apr 11, 2025
6be3672
Merge pull request #9 from zahidulsilam/zahid-team-leader_question9
zahidulsilam Apr 11, 2025
e4dfc50
Zahid team leader question10
zahidulsilam Apr 11, 2025
4196ed8
Merge pull request #10 from zahidulsilam/zahid-team-leader_question10
zahidulsilam Apr 11, 2025
0b465d3
Zahid team leader question11
zahidulsilam Apr 11, 2025
a047995
Merge pull request #11 from zahidulsilam/zahid-team-leader_question11
zahidulsilam Apr 11, 2025
39020c7
Zahid team leader question12
zahidulsilam Apr 11, 2025
0bddf3b
Merge pull request #12 from zahidulsilam/zahid-team-leader_question12
zahidulsilam Apr 11, 2025
25a7c4f
Created using Colab
Mohammed-1-IT Apr 16, 2025
b8a0fef
Update Welcome_to_Colab(M).ipynb
Mohammed-1-IT Apr 16, 2025
a538bee
Asem Ansuer for Q 1 from week _2
Asem-Altaweel Apr 18, 2025
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
222 changes: 222 additions & 0 deletions Asem_Answers_Week1_in_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# Q1: Write a Python code that prints numbers from 1 to 10 on the screen.

for i in range(1, 11):
print(i)

# Q2:Take a number input from the user and write a Python program that prints even numbers up to this number on the screen.
# Do this first with 'for' and then with 'while' loops.
user_input = input('Please Enter Number')
i=0
for i in range(i,int(user_input)):
if i%2 == 0:
print(i)

i = 0
user_input = input('Please Enter Number')
while i <= int(user_input):
if i == 0 :
print(i)
i += 1
if i%2 == 0 :
if i > int (user_input):
break
print(i)

# Q3: Write a Python code that receives a start and end value from the user
# and prints all the numbers between these values ​​(including the end value) on the screen.
Start_Value = input('Enter a start Number ')
End_Value = input('Enter an End Number')
if int(Start_Value) > int(End_Value):
print("End Number Should be Biger Than Start Number ")
Start_Value = input('Enter a start Number ')
End_Value = input('Enter an End Number')
x = range(int(Start_Value), int(End_Value) + 1)
for n in x:
print(n)
else:
x = range(int(Start_Value), int(End_Value) + 1)
for n in x:
print(n)

# Q4: Get a number from the user and write a Python code that prints whether this number is odd or even
user_input = int(input('Inter integer number'))
if user_input % 2 == 0 :
print("This Number is Even")
else:
print('This Number is Odd')

# Q5: Write a Python program that takes a positive integer input from the user and calculates its factorial.
# Factorial is the product of all positive integers between a number itself and 1.
# For example: if the user entered 5, the program should give the following output:
# Enter a number from the user: 5
# Factorial: 120
number = int(input("Enter a positive integer to calculate its factorial: "))
factorial = 1
i = 1
while i <= number:
factorial *= i
i += 1
print("The factorial of", number , " is:", factorial)

# Q6: Write a Python code that receives a number from the user and checks whether this number is prime.
num = int (input("Insert Positive integer Number"))
if num < 0:
print("The Number in negative , inter a positive Number " )
elif num == 0 or num == 1 :
print(num, "is not a prime number")
elif num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
print(num, "is not a prime number")

break
else:
print(num, "is a prime number")

# Q7: How to create a loop that calculates the Fibonacci sequence
# and returns the result as a list containing numbers up to a certain limit?
Num_terms = int(input("How many terms? "))

# first two terms
x = 0
y = 1

num_list =[x]
# check if the number of terms is valid
if Num_terms <= 0:
print("Please enter a positive integer")
# if there is only one term, return n1
elif Num_terms == 1:
print("Fibonacci sequence upto",Num_terms,":",num_list)

# generate fibonacci sequence
else:
num_list = [x,y]
count=2
while count < Num_terms:
z = x + y
num_list.append(z)
# update values
x = y
y = z
count +=1
print("Fibonacci sequence upto",Num_terms,":",num_list)

# Q8: Write a Python code that takes a word from the user and prints the reverse of this word on the screen.
word = input("Input a word to reverse: ")
for char in range(len(word) - 1, -1, -1):
# Print each character from the word in reverse order without a new line (end="")
print(word[char], end="")

# Q9: How to create a combination of loop and conditional statement that takes a word input from the user
# and checks whether that word is a palindrome (the same when read backwards)?
word = input("Inter a word to check if it is palindrome ")
first = 0
length = len(word)
last = length
half = int(length/ 2)

while half > 0 :
if word[first] != word[last-1]:
print("This word is not palindrome")

break
first += 1
last -= 1
half -= 1
if half <= 1:
print("This word is a palindrome")

#Question 10: Write the code that calculates the person's weight index and returns the result as underweight,
# overweight or overweight according to the index value. (You can look on the internet for the weight index calculation)
#To do this, ask the user for their weight and height measurements. weight index
# If it is below 25, it is weak,
# Between 25-30 is normal,
# If you are over 30-40, you are overweight.
# If you are over 40, you are overweight.

kg = float(input("Please enter your weight in Kg and more than zero "))
while kg <= 0 :
kg = float(input("Please re-enter your weight in Kg and more than zero"))

le = float(input('Please enter your height in M and more than zero'))
while le <= 0 :
le = float(input('Please re-enter your height in M and more than zero '))

bmi = le / (kg *kg)
if bmi > 40 :(print("You are Highly overweight."))
elif bmi > 30 :
print('You are Overweight.')
elif bmi >= 25 :
print('Your Weight is Normal ')
else: print(' You are underweight ')

# Q 11: How to write a Python program that finds the largest of three numbers
# entered by a user?
x = float(input("put the first num" ))
y = float(input("put the second num" ))
z= float(input("put the third num" ))
largest = x
if y >= x :
largest = y
if y <= z :
largest = z
elif x<= z:
largest = z
print("The largest Num is :", largest)

# Q12: Get Midterm and Final grades from a student for any course.
# The sum of 40% of the midterm exam grade and 60% of the final
# grade will give the year-end average.
# If the average is below 50, "FAILED" will appear on the screen
# and if it is 50 or above, "CSUCESSFUL" will be displayed on the screen.
# This printing process is 4 lessons.
# and the lessons will be written one after the other.

eng_res = ""
math_res = ""
his_res = ""
geo_res = ""
md_E = -1
while md_E not in range (0,100):
md_E = float(input('Enter the student Midterm English grades'))
fl_E = -1
while fl_E not in range (0,101):
fl_E = float(input('Enter the student English Final grades'))
if (md_E * 0.4 + fl_E *0.6) >= 50 :
eng_res= "Passed"
else:
eng_res= 'Failed'
md_E = -1
while md_E not in range (0,100):
md_E = float(input('Enter the student Midterm Math grades'))
fl_E = -1
while fl_E not in range (0,101):
fl_E = float(input('Enter the student Math Final grades'))
if (md_E * 0.4 + fl_E *0.6) >= 50 :
math_res= "Passed"
else:
math_res= 'Failed'
md_E = -1
while md_E not in range (0,100):
md_E = float(input('Enter the student Midterm History grades'))
fl_E = -1
while fl_E not in range (0,101):
fl_E = float(input('Enter the student Final History grades'))
if (md_E * 0.4 + fl_E *0.6) >= 50 :
his_res= "Passed"
else:
his_res= 'Failed'
md_E = -1
while md_E not in range (0,100):
md_E = float(input('Enter the student Midterm Geography grades'))
fl_E = -1
while fl_E not in range (0,101):
fl_E = float(input('Enter the student Final Geography grades'))
if (md_E * 0.4 + fl_E *0.6) >= 50 :
geo_res= "Passed"
else:
geo_res= 'Failed'
print("English Result is:",eng_res,"\nMath Result is:",math_res,"\nHistory result is:",his_res,"\nGeography Result is:",geo_res)

3 changes: 3 additions & 0 deletions Week_1_Answers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Write a Python code that prints numbers from 1 to 10 on the screen.
for i in range(1, 11):
print(i)
37 changes: 37 additions & 0 deletions Welcome_to_Colab.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#The list:
students=[{'name':'Ahmet','sname':'yilmaz','mid':85,'final':90,'oral':75,'GPA':0},
{'name':'Mehmit','sname':'Dimer','mid':92,'final':88,'oral':76,'GPA':0},
{'name':'Ayse','sname':'Kaya','mid':78,'final':89,'oral':95,'GPA':0},
{'name':'Zynep','sname':'Celik','mid':65,'final':70,'oral':80,'GPA':0},
{'name':'Ali','sname':'Kara','mid':50,'final':60,'oral':55,'GPA':0},
{'name':'Fatma','sname':'Yildiz','mid':88,'final':85,'oral':90,'GPA':0},
{'name':'Murat','sname':'Aydin','mid':72,'final':68,'oral':74,'GPA':0},
{'name':'Elif','sname':'Aksoy','mid':95,'final':90,'oral':88,'GPA':0},
{'name':'Hakan','sname':'Ozturk','mid':45,'final':50,'oral':55,'GPA':0},
{'name':'Canan','sname':'Tas','mid':80,'final':75,'oral':82,'GPA':0}]
#The answers:
#The first requirement(Calculate each student's GPA and add it to the dictionary):
for i in range(len(students)):
GPA=(students[i]['mid']+students[i]['final']+students[i]['oral'])/3
students[i]['GPA']=GPA
print(students[i])
##The second requirement(Find the student with the highest GPA and print it on the screen):
maxGPA=max(students,key=lambda x:x['GPA'])
print(maxGPA)
print(maxGPA['name'],maxGPA['sname'],maxGPA['GPA'],maxGPA['mid'],maxGPA['final'],maxGPA['oral'])
student_data = []
for student in students:
student_data.append((student['name'], student['sname']))

student_data
#The Third and fourth requirements(Sort students by name and surname alphabetically)and(Separate each student's name from their surname and store them in a separate tuple and add them to a list):
sorted_students = sorted(students, key=lambda student: (student['name'], student['sname']))

#The fifth requirement(Keep students with a GPA below 70 in a cluster):
for student in sorted_students:
print(f"{student['name']},{student['sname']}")
low_gpa_students = set()
for student in students:
if student['GPA'] < 70:
low_gpa_students.add(student['name'])
low_gpa_students
4 changes: 4 additions & 0 deletions zahid_team_leader_week1_question1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Question #1
i=0
for i in range(1,13):
print(i)
15 changes: 15 additions & 0 deletions zahid_team_leader_week1_question10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Question no 10

weight = int(input('Please Enter Weight'))
height = int(input('Please Enter Height in cm'))
# convert cm to meters
meter = height/100
BMI = round(weight/(meter**2))
if(BMI < 25):
print("You are Week!")
elif(BMI >= 25 and BMI <= 30):
print("You are Normal!")
elif(BMI > 30 and BMI <= 40):
print("You are over weight!")
else:
print("You are obese weight!")
11 changes: 11 additions & 0 deletions zahid_team_leader_week1_question11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Question no 11

number1 = int(input('Please Enter first number'))
number2 = int(input('Please Enter 2nd number'))
number3 = int(input('Please Enter 3rd number'))
if number1 > number2 and number1 > number3:
print("number1 is Largest ")
elif number2 > number1 and number2 > number3:
print("number2 is Largest ")
else:
print("Number2 is Largest")
11 changes: 11 additions & 0 deletions zahid_team_leader_week1_question12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Question no 12

for i in range(1,5):
seconde_term = float(input(f"Enter midterm grade Subject {i}:"))
final_term = float(input(f"Enter final term grade {i}:"))
average_marks_subject = (seconde_term * 0.4) + (final_term * 0.6)
if average_marks_subject >= 50:
final_result = "SUCCESSFUL"
else:
final_result = "FAILED"
print(f"Averege Marks{average_marks_subject:.2f} Result {final_result}")
10 changes: 10 additions & 0 deletions zahid_team_leader_week1_question2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#Quesion #2
user_input = input('Please Enter Number')
i = 1
for i in range(i,int(user_input)):
if i%2 == 0:
print(i)
while i <= int(user_input):
i += 1
if i%2 == 0:
print(i)
9 changes: 9 additions & 0 deletions zahid_team_leader_week1_question3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Question #3
value1 = int(input('Please Enter First Number'))
value2 = int(input('Please Enter 2nd Number'))
if value1 > value2:
print("Error! Please Enter Valid first Value should less the 2nd value")
else:
while value1 < value2:
value1 += 1
print(value1)
6 changes: 6 additions & 0 deletions zahid_team_leader_week1_question4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Question #4
value1 = int(input('Please Enter Number'))
if value1 % 2 == 0:
print('Even Number')
else:
print("Odd Number")
7 changes: 7 additions & 0 deletions zahid_team_leader_week1_question5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Question #5

number = int(input('Please Enter Number'))
factorial = 1
for i in range(2, number + 1):
factorial *= i
print(factorial)
8 changes: 8 additions & 0 deletions zahid_team_leader_week1_question6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Question # 6
value1=int(input('enter the number'))
for i in range(2, int(value1**0.5) + 1):
if value1 % i == 0:
print(str(value1)+" Not a Prime number ")
break
print(str(value1)+" Not a Prime number ")
# Need To bit discuss
11 changes: 11 additions & 0 deletions zahid_team_leader_week1_question7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Question # 7
number = int(input('Please Enter Number'))
i=0
numer_calc = 0
add_number = 1
while i < number:
final_number = numer_calc + add_number
print(numer_calc)
numer_calc = add_number
add_number = final_number
i += 1
8 changes: 8 additions & 0 deletions zahid_team_leader_week1_question8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Question no 8

text = input('Please Enter Word')
tlen = len(text) - 1
new_text = ''
for i in range(tlen, -1, -1):
new_text = new_text+text[i]
print(new_text)
8 changes: 8 additions & 0 deletions zahid_team_leader_week1_question9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Question no 9

text = input('Please Enter Word')
revers_word = text[::-1]
if text == revers_word:
print("word is a palindrome")
else:
print("word is Not a palindrome")