139k views
4 votes
Pls help me pass my finals!!​

Pls help me pass my finals!!​-example-1
User Jhilom
by
4.3k points

1 Answer

2 votes

Answer:

(a): power(2&-2)

The code is as follows:

power = 2**-2

print(power)

(b): Largest and smallest in a list

The code is as follows:

num = [33,6,11,100,456,109,-4,366]

smallest= min(num)

largest= max(num)

print(smallest)

print(largest)

(c): Loop in Python

(i) Loop are instructions that are repeated until a certain condition is met;

(ii) For loop, in python are used to iterate over a sequence or through a certain range;

The syntax is:

for loop_element in range(iterating_range):

The following is an illustration of for loop that iterates 5 times

for i in range(5):

Step-by-step explanation:

(a): power(2&-2)

The ** is used to calculate power.

So, 2**-2 represents 2 raise to power -2

power = 2**-2

This prints the calculated power

print(power)

(b): Largest and smallest in a list

This initializes the list

num = [33,6,11,100,456,109,-4,366]

This calculates the smallest using min() function

smallest= min(num)

This calculates the largest using max() function

largest= max(num)

This prints the smallest and the largest

print(smallest)

print(largest)

(c): See answer section

User Andreas Herd
by
4.3k points