From f3f7b6b3392e889e64035c5ef4b1d4066b2ab10d Mon Sep 17 00:00:00 2001 From: Asmaa AlSaggaf Date: Wed, 1 Jul 2020 14:01:28 +0300 Subject: [PATCH 1/2] fixed content fixed the content based on the ppt --- teens-program/day2/activity1.py | 11 ++++--- teens-program/day2/demo1.py | 13 +++++--- teens-program/day3/activity2.py | 26 +++++++--------- teens-program/day3/activity3.py | 31 +++++++++++++------ teens-program/day3/activity4.py | 25 ++------------- teens-program/day3/activity5.py | 4 +-- teens-program/day3/challenge1.py | 34 +++++++++------------ teens-program/day3/challenge2.py | 22 +++++++++++-- teens-program/day3/challenge3.py | 4 +-- teens-program/day3/demo2.py | 8 ++--- teens-program/day3/demo3.py | 5 +++ teens-program/day3/demo4.py | 5 +++ teens-program/day4/challenge1.py | 29 ++++++++++++++++++ teens-program/day4/challenge1_instructor.py | 25 +++++++++++++++ 14 files changed, 157 insertions(+), 85 deletions(-) create mode 100644 teens-program/day3/demo3.py create mode 100644 teens-program/day3/demo4.py create mode 100644 teens-program/day4/challenge1.py create mode 100644 teens-program/day4/challenge1_instructor.py diff --git a/teens-program/day2/activity1.py b/teens-program/day2/activity1.py index a424543..eaceb62 100644 --- a/teens-program/day2/activity1.py +++ b/teens-program/day2/activity1.py @@ -1,4 +1,7 @@ -# print(’hi’) -# print (’hi’ -# print(’hi) -# prin (’hi’) \ No newline at end of file +#print('hi') + +#print ('hi' + +#print('hi) + +#prin ('hi') \ No newline at end of file diff --git a/teens-program/day2/demo1.py b/teens-program/day2/demo1.py index ee07cfc..b9c31fd 100644 --- a/teens-program/day2/demo1.py +++ b/teens-program/day2/demo1.py @@ -1,7 +1,12 @@ -x = 1 -y = 4 -sum = x + y -print(sum) +#x = 2 +#y = 4 +#sum = x + y +#print(sum) name = 'Asmaa' + +print(name) +print(name) +print(name) +print(name) print(name) \ No newline at end of file diff --git a/teens-program/day3/activity2.py b/teens-program/day3/activity2.py index b651a77..5ee6c84 100644 --- a/teens-program/day3/activity2.py +++ b/teens-program/day3/activity2.py @@ -1,17 +1,13 @@ -weekend = True -test_sunday = False +number = 10 -if (weekend == True and test_sunday == False): - print('We will go out.') -elif (weekend != True or test_sunday != False): - print('We will not go out.') +if (number > 0): + print('The number ', number,' is positive') +else: + print('The number ', number,' is negative') -# Extra -# if (weekend == True and test_sunday == False): -# print('We will go out.') -# elif (weekend != True and test_sunday == False): -# print('We will not go out; it is not the weekend.') -# elif (weekend == True and test_sunday != False): -# print('We will not go out; you have a test on sunday.') -# else: -# print('We will not go out; it is not the weekend and you have a test on sunday.') \ No newline at end of file +'''number = -10 + +if (number > 0): + print('The number ', number,' is positive') +else: + print('The number ', number,' is negative')''' \ No newline at end of file diff --git a/teens-program/day3/activity3.py b/teens-program/day3/activity3.py index 5ee6c84..8c34ee7 100644 --- a/teens-program/day3/activity3.py +++ b/teens-program/day3/activity3.py @@ -1,13 +1,24 @@ -number = 10 +grade = input('How much did you score for the test?') -if (number > 0): - print('The number ', number,' is positive') +if int(grade) >= 60: + print('Congrats, you succeed!') else: - print('The number ', number,' is negative') + print('Sorry, you failed') -'''number = -10 - -if (number > 0): - print('The number ', number,' is positive') -else: - print('The number ', number,' is negative')''' \ No newline at end of file +# is_valid = False +# +# while is_valid is False: +# grade = input('How much did you score for the test?') +# try: +# if int(grade) >= 0 and int(grade) <= 100: +# is_valid = True +# else: +# print('Please enter a valid number') +# except: +# print('Please enter a valid number') +# +# +# if int(grade) >= 60: +# print('Congrats, you succeed!') +# else: +# print('Sorry, you failed') \ No newline at end of file diff --git a/teens-program/day3/activity4.py b/teens-program/day3/activity4.py index 8c34ee7..e3a4d14 100644 --- a/teens-program/day3/activity4.py +++ b/teens-program/day3/activity4.py @@ -1,24 +1,3 @@ -grade = input('How much did you score for the test?') +fav_numbers = [2, 4, 5, 7, 3] -if int(grade) >= 60: - print('Congrats, you succeed!') -else: - print('Sorry, you failed') - -# is_valid = False -# -# while is_valid is False: -# grade = input('How much did you score for the test?') -# try: -# if int(grade) >= 0 and int(grade) <= 100: -# is_valid = True -# else: -# print('Please enter a valid number') -# except: -# print('Please enter a valid number') -# -# -# if int(grade) >= 60: -# print('Congrats, you succeed!') -# else: -# print('Sorry, you failed') \ No newline at end of file +print(fav_numbers) \ No newline at end of file diff --git a/teens-program/day3/activity5.py b/teens-program/day3/activity5.py index 415a986..c3b0cfc 100644 --- a/teens-program/day3/activity5.py +++ b/teens-program/day3/activity5.py @@ -1,5 +1,5 @@ fav_numbers = [2, 4, 5, 7, 3] -sum = fav_numbers[0] + fav_numbers[1] + fav_numbers[2] + fav_numbers[3] + fav_numbers[4] +big_number = fav_numbers[3] -print(sum) \ No newline at end of file +print(big_number) \ No newline at end of file diff --git a/teens-program/day3/challenge1.py b/teens-program/day3/challenge1.py index 5e0becb..b651a77 100644 --- a/teens-program/day3/challenge1.py +++ b/teens-program/day3/challenge1.py @@ -1,21 +1,17 @@ -hot = True -moderate = False -cold = False +weekend = True +test_sunday = False -soup = False -watermelon = False -pizza = False +if (weekend == True and test_sunday == False): + print('We will go out.') +elif (weekend != True or test_sunday != False): + print('We will not go out.') -if hot: - watermelon = True - -elif moderate: - pizza = True - - -elif cold: - soup = True - -print("soup:", soup) -print("watermelon:", watermelon) -print("pizza:", pizza) +# Extra +# if (weekend == True and test_sunday == False): +# print('We will go out.') +# elif (weekend != True and test_sunday == False): +# print('We will not go out; it is not the weekend.') +# elif (weekend == True and test_sunday != False): +# print('We will not go out; you have a test on sunday.') +# else: +# print('We will not go out; it is not the weekend and you have a test on sunday.') \ No newline at end of file diff --git a/teens-program/day3/challenge2.py b/teens-program/day3/challenge2.py index e3a4d14..5e0becb 100644 --- a/teens-program/day3/challenge2.py +++ b/teens-program/day3/challenge2.py @@ -1,3 +1,21 @@ -fav_numbers = [2, 4, 5, 7, 3] +hot = True +moderate = False +cold = False -print(fav_numbers) \ No newline at end of file +soup = False +watermelon = False +pizza = False + +if hot: + watermelon = True + +elif moderate: + pizza = True + + +elif cold: + soup = True + +print("soup:", soup) +print("watermelon:", watermelon) +print("pizza:", pizza) diff --git a/teens-program/day3/challenge3.py b/teens-program/day3/challenge3.py index c3b0cfc..415a986 100644 --- a/teens-program/day3/challenge3.py +++ b/teens-program/day3/challenge3.py @@ -1,5 +1,5 @@ fav_numbers = [2, 4, 5, 7, 3] -big_number = fav_numbers[3] +sum = fav_numbers[0] + fav_numbers[1] + fav_numbers[2] + fav_numbers[3] + fav_numbers[4] -print(big_number) \ No newline at end of file +print(sum) \ No newline at end of file diff --git a/teens-program/day3/demo2.py b/teens-program/day3/demo2.py index 762edd4..054c00c 100644 --- a/teens-program/day3/demo2.py +++ b/teens-program/day3/demo2.py @@ -1,5 +1,5 @@ -fruits = ['apple', 'banana', 'orange', 'mango'] +hello_world = "hello" + " " + "world" +print(hello_world) -my_favourite_fruit = fruits[1] - -print(my_favourite_fruit) \ No newline at end of file +lots_of_hellos = "hello" * 3 +print(lots_of_hellos) \ No newline at end of file diff --git a/teens-program/day3/demo3.py b/teens-program/day3/demo3.py new file mode 100644 index 0000000..3c362cf --- /dev/null +++ b/teens-program/day3/demo3.py @@ -0,0 +1,5 @@ +allergy = False + +if (allergy == False): + print('add nuts.') +print('make it into small balls.') diff --git a/teens-program/day3/demo4.py b/teens-program/day3/demo4.py new file mode 100644 index 0000000..762edd4 --- /dev/null +++ b/teens-program/day3/demo4.py @@ -0,0 +1,5 @@ +fruits = ['apple', 'banana', 'orange', 'mango'] + +my_favourite_fruit = fruits[1] + +print(my_favourite_fruit) \ No newline at end of file diff --git a/teens-program/day4/challenge1.py b/teens-program/day4/challenge1.py new file mode 100644 index 0000000..f3ec2be --- /dev/null +++ b/teens-program/day4/challenge1.py @@ -0,0 +1,29 @@ +# Rolling the dice +# Auther: + +import random +import time + +def printDice(num): + time.sleep(2) + print("*****") + print("* " + str(num) + " *") + print("*****") + print() + +min = 1 +max = 6 + +roll = "yes" + +#TODO: write the while condititons +while : + #TODO: take user input for number of rolls + numberOfdices = int(input('How many dices you want to roll? ')) + print("Rolling the dices ...") + + #TODO: write the for loop + for : + printDice(random.randint(min,max)) + #TODO: take user input for new rolling + roll = \ No newline at end of file diff --git a/teens-program/day4/challenge1_instructor.py b/teens-program/day4/challenge1_instructor.py new file mode 100644 index 0000000..26b2aa4 --- /dev/null +++ b/teens-program/day4/challenge1_instructor.py @@ -0,0 +1,25 @@ +# Rolling the dice +# Auther: Asmaa Alsaggaf + +import random +import time + +def printDice(num): + time.sleep(2) + print("*****") + print("* " + str(num) + " *") + print("*****") + print() + +min = 1 +max = 6 + +roll = "yes" + +while roll.lower() == "yes" or roll.lower() == "y": + numberOfdices = int(input('How many dices you want to roll? ')) + if numberOfdices != 0: + print("Rolling the dices ...") + for dice in range(numberOfdices): + printDice(random.randint(min,max)) + roll = input('Do you want to roll again? (yes/no) ') \ No newline at end of file From e7bcd9d4b342c9a15ec29a8636ddda677cd09a53 Mon Sep 17 00:00:00 2001 From: Asmaa AlSaggaf Date: Mon, 6 Jul 2020 14:30:27 +0300 Subject: [PATCH 2/2] final edits --- teens-program/day3/activity2.py | 8 +---- teens-program/day3/activity3.py | 35 ++++++++----------- teens-program/day3/activity4.py | 25 +++++++++++-- teens-program/day3/activity5.py | 4 +-- teens-program/day3/activity6.py | 5 +++ teens-program/day3/challenge1.py | 23 ++++-------- teens-program/day3/challenge2.py | 1 - teens-program/day3/hints/activity3.py | 12 +++++++ teens-program/day3/hints/challenge1.py | 14 ++++++++ teens-program/day3/hints/challenge2 | 27 ++++++++++++++ teens-program/day3/hints/mix.py | 20 +++++++++++ teens-program/day4/activity1.py | 10 ++++++ teens-program/day4/challenge1.py | 31 ++-------------- teens-program/day4/challenge2.py | 29 +++++++++++++++ ...instructor.py => challenge2_instructor.py} | 0 teens-program/day4/challenge3.py | 33 +++++++++++++++++ teens-program/day4/challenge3_instructor.py | 22 ++++++++++++ teens-program/day4/challenge4_instructor.py | 22 ++++++++++++ teens-program/day4/demo1.py | 5 +++ teens-program/day4/demo2.py | 9 +++++ teens-program/day4/demo3.py | 10 ++++++ teens-program/day4/demo4.py | 10 ++++++ teens-program/day4/demo5.py | 4 +++ 23 files changed, 281 insertions(+), 78 deletions(-) create mode 100644 teens-program/day3/activity6.py create mode 100644 teens-program/day3/hints/activity3.py create mode 100644 teens-program/day3/hints/challenge1.py create mode 100644 teens-program/day3/hints/challenge2 create mode 100644 teens-program/day3/hints/mix.py create mode 100644 teens-program/day4/activity1.py create mode 100644 teens-program/day4/challenge2.py rename teens-program/day4/{challenge1_instructor.py => challenge2_instructor.py} (100%) create mode 100644 teens-program/day4/challenge3.py create mode 100644 teens-program/day4/challenge3_instructor.py create mode 100644 teens-program/day4/challenge4_instructor.py create mode 100644 teens-program/day4/demo1.py create mode 100644 teens-program/day4/demo2.py create mode 100644 teens-program/day4/demo3.py create mode 100644 teens-program/day4/demo4.py create mode 100644 teens-program/day4/demo5.py diff --git a/teens-program/day3/activity2.py b/teens-program/day3/activity2.py index 5ee6c84..87c8203 100644 --- a/teens-program/day3/activity2.py +++ b/teens-program/day3/activity2.py @@ -1,13 +1,7 @@ number = 10 +# number = - 10 if (number > 0): print('The number ', number,' is positive') else: print('The number ', number,' is negative') - -'''number = -10 - -if (number > 0): - print('The number ', number,' is positive') -else: - print('The number ', number,' is negative')''' \ No newline at end of file diff --git a/teens-program/day3/activity3.py b/teens-program/day3/activity3.py index 8c34ee7..b651a77 100644 --- a/teens-program/day3/activity3.py +++ b/teens-program/day3/activity3.py @@ -1,24 +1,17 @@ -grade = input('How much did you score for the test?') +weekend = True +test_sunday = False -if int(grade) >= 60: - print('Congrats, you succeed!') -else: - print('Sorry, you failed') +if (weekend == True and test_sunday == False): + print('We will go out.') +elif (weekend != True or test_sunday != False): + print('We will not go out.') -# is_valid = False -# -# while is_valid is False: -# grade = input('How much did you score for the test?') -# try: -# if int(grade) >= 0 and int(grade) <= 100: -# is_valid = True -# else: -# print('Please enter a valid number') -# except: -# print('Please enter a valid number') -# -# -# if int(grade) >= 60: -# print('Congrats, you succeed!') +# Extra +# if (weekend == True and test_sunday == False): +# print('We will go out.') +# elif (weekend != True and test_sunday == False): +# print('We will not go out; it is not the weekend.') +# elif (weekend == True and test_sunday != False): +# print('We will not go out; you have a test on sunday.') # else: -# print('Sorry, you failed') \ No newline at end of file +# print('We will not go out; it is not the weekend and you have a test on sunday.') \ No newline at end of file diff --git a/teens-program/day3/activity4.py b/teens-program/day3/activity4.py index e3a4d14..8c34ee7 100644 --- a/teens-program/day3/activity4.py +++ b/teens-program/day3/activity4.py @@ -1,3 +1,24 @@ -fav_numbers = [2, 4, 5, 7, 3] +grade = input('How much did you score for the test?') -print(fav_numbers) \ No newline at end of file +if int(grade) >= 60: + print('Congrats, you succeed!') +else: + print('Sorry, you failed') + +# is_valid = False +# +# while is_valid is False: +# grade = input('How much did you score for the test?') +# try: +# if int(grade) >= 0 and int(grade) <= 100: +# is_valid = True +# else: +# print('Please enter a valid number') +# except: +# print('Please enter a valid number') +# +# +# if int(grade) >= 60: +# print('Congrats, you succeed!') +# else: +# print('Sorry, you failed') \ No newline at end of file diff --git a/teens-program/day3/activity5.py b/teens-program/day3/activity5.py index c3b0cfc..e3a4d14 100644 --- a/teens-program/day3/activity5.py +++ b/teens-program/day3/activity5.py @@ -1,5 +1,3 @@ fav_numbers = [2, 4, 5, 7, 3] -big_number = fav_numbers[3] - -print(big_number) \ No newline at end of file +print(fav_numbers) \ No newline at end of file diff --git a/teens-program/day3/activity6.py b/teens-program/day3/activity6.py new file mode 100644 index 0000000..c3b0cfc --- /dev/null +++ b/teens-program/day3/activity6.py @@ -0,0 +1,5 @@ +fav_numbers = [2, 4, 5, 7, 3] + +big_number = fav_numbers[3] + +print(big_number) \ No newline at end of file diff --git a/teens-program/day3/challenge1.py b/teens-program/day3/challenge1.py index b651a77..8a814be 100644 --- a/teens-program/day3/challenge1.py +++ b/teens-program/day3/challenge1.py @@ -1,17 +1,8 @@ -weekend = True -test_sunday = False +number = 10 -if (weekend == True and test_sunday == False): - print('We will go out.') -elif (weekend != True or test_sunday != False): - print('We will not go out.') - -# Extra -# if (weekend == True and test_sunday == False): -# print('We will go out.') -# elif (weekend != True and test_sunday == False): -# print('We will not go out; it is not the weekend.') -# elif (weekend == True and test_sunday != False): -# print('We will not go out; you have a test on sunday.') -# else: -# print('We will not go out; it is not the weekend and you have a test on sunday.') \ No newline at end of file +if (number > 0): + print('The number is positive') +elif(number == 0): + print('The number is zero') +else: + print('The number is negative') \ No newline at end of file diff --git a/teens-program/day3/challenge2.py b/teens-program/day3/challenge2.py index 5e0becb..b2c1266 100644 --- a/teens-program/day3/challenge2.py +++ b/teens-program/day3/challenge2.py @@ -12,7 +12,6 @@ elif moderate: pizza = True - elif cold: soup = True diff --git a/teens-program/day3/hints/activity3.py b/teens-program/day3/hints/activity3.py new file mode 100644 index 0000000..f67d883 --- /dev/null +++ b/teens-program/day3/hints/activity3.py @@ -0,0 +1,12 @@ +# Activity: Print the result of the student based on his/her score + +# Use the following code to take an input from the user and determine the result + +# TODO: Take a user input asking about the score. Note: the user input is a string +grade = + +# TODO: Write "if condition" based on the score +if (): + print('Congrats, you succeed!') +else: + print('Sorry, you failed') \ No newline at end of file diff --git a/teens-program/day3/hints/challenge1.py b/teens-program/day3/hints/challenge1.py new file mode 100644 index 0000000..54e4ad7 --- /dev/null +++ b/teens-program/day3/hints/challenge1.py @@ -0,0 +1,14 @@ +# Challenge: determint whether the number is positive, negative, or zero + +# Use the following code to determine if the number is positive, negative, or zero + +number = 10 + +if (number > 0): + print('The number is positive') +# TODO: Write the condition between () اكتبي الشرط بين +elif(): + # TODO: print a sentence that says "The number is zero" + print('') +else: + print('The number is negative') \ No newline at end of file diff --git a/teens-program/day3/hints/challenge2 b/teens-program/day3/hints/challenge2 new file mode 100644 index 0000000..155524e --- /dev/null +++ b/teens-program/day3/hints/challenge2 @@ -0,0 +1,27 @@ +# Challenge: Recommend a meal based on the weather + +# Use the following code to determine what meal to Recommend + +hot = True +moderate = False +cold = False + +soup = False +watermelon = False +pizza = False + +# TODO: Write "if condition" for watermelon +if hot: + watermelon = True + +# TODO: Write "elif condition" for pizza +elif moderate: + pizza = True + +# TODO: Write "elif condition" for soup +elif cold: + soup = True + +print("soup:", soup) +print("watermelon:", watermelon) +print("pizza:", pizza) diff --git a/teens-program/day3/hints/mix.py b/teens-program/day3/hints/mix.py new file mode 100644 index 0000000..2e4c87e --- /dev/null +++ b/teens-program/day3/hints/mix.py @@ -0,0 +1,20 @@ +# Activity: Write your favorite numbers in a list +# Activity: Print the biggest number in the list using indexing +# Challenge: Print the sum of the numbers in the list using indexing + +# Use the following code to write your favorite numbers in a list, print the biggest number, sum of the numbers using indexing + +# TODO: Write your favorite numbers in a list +fav_numbers = + +print('The list of my favorite numbers: ' + str(fav_numbers)) + +# TODO: Print the biggest number using indexing +biggest_number = + +print('The biggest number in the list is: ' + str(biggest_number)) + +# TODO: Sum the numbers using indexing +sum = + +print('The sume of the numbers is: ' + str(sum)) \ No newline at end of file diff --git a/teens-program/day4/activity1.py b/teens-program/day4/activity1.py new file mode 100644 index 0000000..098657b --- /dev/null +++ b/teens-program/day4/activity1.py @@ -0,0 +1,10 @@ +ages = [14, 15, 14, 16, 17, 19, 18] +n = 7 +sum = 0 + +for i in ages: + sum = sum + i + +average = sum / n + +print(average) \ No newline at end of file diff --git a/teens-program/day4/challenge1.py b/teens-program/day4/challenge1.py index f3ec2be..c80083a 100644 --- a/teens-program/day4/challenge1.py +++ b/teens-program/day4/challenge1.py @@ -1,29 +1,4 @@ -# Rolling the dice -# Auther: +num = [1, 4, 7, 8, 11] -import random -import time - -def printDice(num): - time.sleep(2) - print("*****") - print("* " + str(num) + " *") - print("*****") - print() - -min = 1 -max = 6 - -roll = "yes" - -#TODO: write the while condititons -while : - #TODO: take user input for number of rolls - numberOfdices = int(input('How many dices you want to roll? ')) - print("Rolling the dices ...") - - #TODO: write the for loop - for : - printDice(random.randint(min,max)) - #TODO: take user input for new rolling - roll = \ No newline at end of file +for i in num: + print(i*2) \ No newline at end of file diff --git a/teens-program/day4/challenge2.py b/teens-program/day4/challenge2.py new file mode 100644 index 0000000..3a8a6ae --- /dev/null +++ b/teens-program/day4/challenge2.py @@ -0,0 +1,29 @@ +# Rolling the dice +# Auther: + +import random +import time + +def printDice(num): + time.sleep(2) + print("*****") + print("* " + str(num) + " *") + print("*****") + print() + +min = 1 +max = 6 + +roll = "yes" + +#TODO: write the while condititons +while : + #TODO: take user input for number of rolls + numberOfdices = + print("Rolling the dices ...") + + #TODO: write the for loop + for : + printDice(random.randint(min,max)) + #TODO: take user input for new rolling + roll = \ No newline at end of file diff --git a/teens-program/day4/challenge1_instructor.py b/teens-program/day4/challenge2_instructor.py similarity index 100% rename from teens-program/day4/challenge1_instructor.py rename to teens-program/day4/challenge2_instructor.py diff --git a/teens-program/day4/challenge3.py b/teens-program/day4/challenge3.py new file mode 100644 index 0000000..3ea23bb --- /dev/null +++ b/teens-program/day4/challenge3.py @@ -0,0 +1,33 @@ +# Guess the number +# Auther: + +import random + +play = "yes" +count = 0 + +#TODO: write the while condititons +while : + # TODO: take user input for number of rounds + numberOfrounds = int(input('How many rounds you want to play? ')) + + + if numberOfrounds != 0: + + # TODO: write the for loop + for : + print("******** Round: " + str(round+1) + " ********") + user = int(input("Choose number between 1 and 5: ")) + computer = random.randint(1,5) + print("Computer: ", computer) + print("User: ", user) + + # TODO: write if condition + if : + # TODO: add 1 to the count + count = count + 1 + + print("You Won " + str(count) + " times!") + + # TODO: take user input for new game + play = \ No newline at end of file diff --git a/teens-program/day4/challenge3_instructor.py b/teens-program/day4/challenge3_instructor.py new file mode 100644 index 0000000..f7baa66 --- /dev/null +++ b/teens-program/day4/challenge3_instructor.py @@ -0,0 +1,22 @@ +# Guess the number +# Auther: Asmaa Alsaggaf + +import random + +play = "yes" +count = 0 + +while play.lower() == "yes" or play.lower() == "y": + numberOfrounds = int(input('How many rounds you want to play? ')) + if numberOfrounds != 0: + for round in range(numberOfrounds): + print("******** Round: " + str(round+1) + " ********") + user = int(input("Choose number between 1 and 5: ")) + computer = random.randint(1,5) + print("Computer: ", computer) + print("User: ", user) + if(user == computer): + count = count + 1 + + print("You Won " + str(count) + " times!") + play = input('Do you want to play again? (yes/no) ') \ No newline at end of file diff --git a/teens-program/day4/challenge4_instructor.py b/teens-program/day4/challenge4_instructor.py new file mode 100644 index 0000000..47a39bb --- /dev/null +++ b/teens-program/day4/challenge4_instructor.py @@ -0,0 +1,22 @@ +# Rock, paper, scissors +# Auther: Asmaa Alsaggaf + +import random + +def computer_turn(): + RPS = ["rock", "paper", "scissors"] + return RPS[random.randint(0,2)] + +play = "yes" + +while play.lower() == "yes" or play.lower() == "y": + numberOfrounds = int(input('How many rounds you want to play? ')) + if numberOfrounds != 0: + print("Rolling the dices ...") + for round in range(numberOfrounds): + user = input("Type rock, paper, or scissors: ") + computer = computer_turn() + if((user.lower() == "rock" and computer.lower == "paper") or + (user.lower() == "rock" and computer.lower == "paper") or + (user.lower() == "rock" and computer.lower == "paper")) + play = input('Do you want to play again? (yes/no) ') \ No newline at end of file diff --git a/teens-program/day4/demo1.py b/teens-program/day4/demo1.py new file mode 100644 index 0000000..10872b1 --- /dev/null +++ b/teens-program/day4/demo1.py @@ -0,0 +1,5 @@ +import random + +num = random.randint(0, 10) + +print(num) \ No newline at end of file diff --git a/teens-program/day4/demo2.py b/teens-program/day4/demo2.py new file mode 100644 index 0000000..030b5f6 --- /dev/null +++ b/teens-program/day4/demo2.py @@ -0,0 +1,9 @@ +def my_function(name): + print("Hello " + name) + +def add_five(x): + return x+5 + +# -------------------------------- + +my_function("Sara") \ No newline at end of file diff --git a/teens-program/day4/demo3.py b/teens-program/day4/demo3.py new file mode 100644 index 0000000..e877bd9 --- /dev/null +++ b/teens-program/day4/demo3.py @@ -0,0 +1,10 @@ +def my_function(name): + print("Hello " + name) + +def add_five(x): + return x+5 + +# -------------------------------- + +num = add_five(10) +print(num) \ No newline at end of file diff --git a/teens-program/day4/demo4.py b/teens-program/day4/demo4.py new file mode 100644 index 0000000..7fc8276 --- /dev/null +++ b/teens-program/day4/demo4.py @@ -0,0 +1,10 @@ +# using for loop +for i in range(1,11): + print(i*7) + +# using while loop +x = 1 + +while x <= 10: + print(x*7) + x = x + 1 \ No newline at end of file diff --git a/teens-program/day4/demo5.py b/teens-program/day4/demo5.py new file mode 100644 index 0000000..1f36acd --- /dev/null +++ b/teens-program/day4/demo5.py @@ -0,0 +1,4 @@ +x = 1 + +while x <= 10: + print(x*7) \ No newline at end of file