Здравствуйте с программироваием в Питоне Напиши результат программы:
1.
str = “ Привет, Python!”
print (str [0:14])
print (str [0])
print (str [0:2])
print (str [0:3])
print (str [-1])
print (str [::2])
print (str [::-1])
print (str [7:])
print (str [-1] *8)
print (str + “Я учусь в 6 классе!”)
2.
print (my_list)
print (my_list [0])
print (my_list [1:3])
print (my_list [2:])
print (second_list*2)
print (my_list +second_list)
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
using namespace std;
int main()
{
srand(time(NULL));
int n, max = 0, index1, min = 0, index2;
cin >> n;
cout << "RANDOM ARRAY:\n";
vector <int> a(n);
for (int i = 0; i < n; i++)
{
a[i] = rand() % 101;
if (a[i] > max) {
max = a[i]; index1 = i;
}
if (a[i] < min || min == 0) {
min = a[i]; index2 = i;
}
cout << a[i] << " ";
}
cout << "\nARRAY:\n";
if (index2 < index1)
{
int x;
x = index2;
index2 = index1;
index1 = x;
}
reverse(a.begin() + index1, a.begin() + index2);
for (int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
return 0;
}
#define UPPERLIMIT 1000
#define LOWERLIMIT 0
#include <iostream>
#include <vector>
#include <cstddef>
#include <algorithm>
#include <ctime>
using namespace std;
class Massive {
public:
virtual void fill() = 0;
virtual int get_max() = 0;
virtual int get_min() = 0;
virtual void reverse(int start, int end) = 0;
virtual void out() = 0;
};
class MassiveHandler : public Massive {
private:
std::vector<int>::iterator result;
public:
std::vector<int> array;
MassiveHandler(std::size_t n) : array(n) {
this->fill();
}
void fill() override {
srand(time(0));
for (int i = 0; i < this->array.size(); ++i)
this->array[i] = rand() % (UPPERLIMIT - LOWERLIMIT + 1) + LOWERLIMIT;
}
void routine() {
this->reverse(this->get_min(), this->get_max());
}
void reverse(int start_v, int end_v) override {
if (start_v > end_v)
swap(start_v, end_v);
for (int i = start_v, j = end_v; i < j; i++, j--)
swap(this->array[i], this->array[j]);
}
int get_max() override {
this->result = std::max_element(this->array.begin(), this->array.end());
return std::distance(this->array.begin(), result);
}
int get_min() override {
this->result = std::min_element(this->array.begin(), this->array.end());
return std::distance(this->array.begin(), result);
}
void out() override {
for (int i = 0; i < this->array.size(); ++i)
cout << this->array[i] << " ";
cout << endl;
}
};
int main() {
int n;
cin >> n;
MassiveHandler *MH = new MassiveHandler(n);
cout << "MAX: " << MH->array[MH->get_max()] << endl;
cout << "MIN: " << MH->array[MH->get_min()] << endl;
cout << endl;
cout << "Before: ";
MH->out();
MH->routine();
cout << "After: ";
MH->out();
}