Предмет: Информатика, автор: Аноним

50 балов даю
напишите код так чтоб можно было сразу вставить в пайтон

Маємо список цілих, заповнений випадковими числами. Використовуючи дані цього масиву створіть список цілих, що містить лише:
■ парні числа з першого списку;
■ непарні числа з першого списку;
■ від’ємні числа з першого списку;
■ додатні числа з першого списку.​

Ответы

Автор ответа: crymovartiom
0

Ответ:

Объяснение:

import random

# Создаем список случайных целых чисел

original_list = [random.randint(-100, 100) for _ in range(10)]

print("Original list:", original_list)

# Создаем список с четными числами

even_numbers = [x for x in original_list if x % 2 == 0]

print("Even numbers:", even_numbers)

# Создаем список с нечетными числами

odd_numbers = [x for x in original_list if x % 2 != 0]

print("Odd numbers:", odd_numbers)

# Создаем список с отрицательными числами

negative_numbers = [x for x in original_list if x < 0]

print("Negative numbers:", negative_numbers)

# Создаем список с положительными числами

positive_numbers = [x for x in original_list if x >= 0]

print("Positive numbers:", positive_numbers)

В этом коде, сначала создается список original_list, который заполнен случайными целыми числами в диапазоне от -100 до 100. Затем, используя генератор списков, создаются 4 списка: even_numbers, `odd_n

Похожие вопросы
Предмет: Английский язык, автор: shevket2007
Помогите пжжжжж!!!

Task 1. Put the verbs in brackets into present simple or present continuous.

a) What language _________ (you / speak) at home?

b) _______ (they / put out) fire now?

c) What _______ (he / paint) right now?

d) Why ________ (your sister / cry) now?

e) How many lessons _________ (he / have) on Monday?


Task 2 Choose the correct response.

1 A: What did you do on Sunday?


B: a I went to a music concert.

b It was nothing special.

2 A: I tried calling you on Friday.


B: a Sorry, I was out.

b I had a good time.

3 A: Did you enjoy the performance?

B: a Not really.

b I don’t believe it.

4 A: I stayed home and watched a film.


B: a What’s the problem?

b Did you enjoy it?



Task 3 . Choose the correct item.

1 When Ryan was young he …….. to go fishing.

A used B using C use

2 They …….. when the rain began.

A were driving B drove C had driven

3 Did Ann …….. play the violin as a child?

A use B use to C used

.4. You can get ____ to a shoulder if you play in a confined space.

A loss В strain С rash

5 Put some_____ cream on that cut.

A antibiotic В painkiller С infected

6 ____Ted and Jim feel stressed out about their exams.

A Either В Both С Neither

7. Margaret suffers_____ terrible headaches.

A of В about С from






Task 4. Match the characteristics to the descriptions .


1) Reliable

2) Considerate

3) Easy-going

4) Patient

5) Cheerful

6) Honest

7) Rude

8) Shy

9) Generous


• He gets along with anyone.

• He always tells the truth.

• She feels nervous around others.

• He is impolite and doesn't have good manners.

• He will never let you down.

• She is polite and thinks about others.

• He doesn't mind waiting

• He is always happy.

• He is always giving people things.


Task 5.Put the verbs in brackets into present perfect, past simple or present perfect continuos.

1. How lo n g ......................(you/study) English?

2. I ..................................(go) to Spain a few years ago.

3. ............................ (you/finish) your project yet, Mike?

4. I ........(work) on it all week, but I .............................. (not/finish) it yet.

5.You look really tired. W h a t............................(you/do)?

Task 6 . Describe your Mom or Dad (7-8 sentences).