خب دوستان دومین تمرین به این صورته که یک لیست رو با اعداد تصادفی پر کنیم (این قسمت رو خودم اضافه کردم خوصله نداشتم دستی عدد بدم :D) بعد باید مجموع اعداد اول داخل لیست حساب بشه و اگه عدد اولی وجود نداشت عدد صفر رو چاپ کنه
کدهاش به این صورته و نتیجه کار هم زیر کدها میتونید ببینید
سعی کردم پرینت زیاد بزارم گیج نشید هرچند اسکریپت خیلی ساده ایه
اینم لینک پروژه در گیت هاب
import random print("Enter the number of list numbers:") nlist = int(input()) numbers = [] sum_odd = 0 for num in range(nlist): numbers.append(random.randint(0,nlist)) print("This List:") print(numbers) print("Odd numbers in list:") for li in range(nlist): if numbers[li]%2 != 0: sum_odd += numbers[li] print(numbers[li]) print("Sum numbres of odd: "+ str(sum_odd))
It is the best time to make some plans for the future and it’s time to be
happy. I’ve read this post and if I could I desire to suggest you some interesting
things or suggestions. Perhaps you could write next articles referring
to this article. I desire to read more things about it!
Thank you my friend
I’ll try to post similar posts on the site in the future
Thank you for your hobbies
Terrific post however I was wanting to know if you could write a litte more on this topic?
I’d be very thankful if you could elaborate a little bit further.
Bless you!
In what part you have trouble, dear friend, let me explain more about you
I was desperately looking for this.
Thank you.
your welcome