Professional Documents
Culture Documents
com/aistudio/projectdetail/3140925
chapter04
提交作业
学生: AL THAMARANI GHADIR ALI MOHAMMED 课程: Python Programming 提交次数: 1 /10 上次提交时间: 2021-11-28 17:31
学生提交截止时间: 2021-11-28 23:59(剩余0天6时30分)
1 of 6 11/28/2021, 5:30 PM
chapter04 - 飞桨AI Studio - 人工智能学习实训社区 https://aistudio.baidu.com/aistudio/projectdetail/3140925
查看教师发布的版本
# Everything divides 0
if (a == 0):
return b
if (b == 0):
return a
# base case
if (a == b):
return a
# a is greater
if (a > b):
return gcd(a-b, b)
return gcd(a, b-a)
2. Find out the first power of 7 larger than 50, output both the power and product.
In [ ] base = 7
exponent = 50
In [ ] even_Sum=0
odd_Sum=0
for num in range(1,100):
if (num%2==0):
even_Sum=even_Sum+num
else:
odd_Sum=odd_Sum+num
print("The sum of Even numbers 1 to 100",even_Sum)
print("The sum of odd numbers 1 to {0} = {1}",odd_Sum)
In [ ] import math
n = int(input("Enter the n number: "))
print ("The factorial of n umber ",n )
print (math.factorial(n))
5. Calculate the class average with unknown student’s amount. stop the input while user key in a
negative score.
In [ ] NUMBER_OF_GRADES = 3
file =open('grades1.in.txt').read().split('\n')
for scores in file:
name_numbers = (scores.split('_'))
2 of 6 11/28/2021, 5:30 PM
chapter04 - 飞桨AI Studio - 人工智能学习实训社区 https://aistudio.baidu.com/aistudio/projectdetail/3140925
6. Use the following approximate formula to evaluate the base e of the natural logarithm until the
absolute value of the last term is less than
In [ ] import math
x = 2
e_to_2 = x**0/math.factorial(0) + x**1/math.factorial(1) + x**2/math.factorial(
print(e_to_2)
while (1) :
count += 1
# Update root
x = root
return root
# Driver code
if __name__ == "__main__" :
3 of 6 11/28/2021, 5:30 PM
chapter04 - 飞桨AI Studio - 人工智能学习实训社区 https://aistudio.baidu.com/aistudio/projectdetail/3140925
11. Output the first 20 entries of Fibonacci Sequence:1,1,2,3,5,8,…with 4 entries per line
4 of 6 11/28/2021, 5:30 PM
chapter04 - 飞桨AI Studio - 人工智能学习实训社区 https://aistudio.baidu.com/aistudio/projectdetail/3140925
case 5:
5 of 6 11/28/2021, 5:30 PM
chapter04 - 飞桨AI Studio - 人工智能学习实训社区 https://aistudio.baidu.com/aistudio/projectdetail/3140925
View Application
PaddlePaddle Service on
WeChat
Baidu Products: PaddlePaddle | PaddlePaddle Github | Baidu Developer Center | ABC Institute | Baidu Institute of Technology | Baidu Xiaolvyun | Dianshi | AI Studio Terms |
© Baidu Terms
6 of 6 11/28/2021, 5:30 PM