Computer Science, asked by jinay946, 6 months ago

Use the range() function to create the following list: [8,4,0,-4] ​

Answers

Answered by ıtʑFᴇᴇʟɓᴇãᴛ
48

\mathtt{\huge{\bf{\underline{\red{Programme:-}}}}}

Programming Language :- \mathcal{\large{\pink{Python}}} ۩

# printing a number

for i in range(10):

print(i, end =" ")

print()

# using range for iteration

l = [8,4,0,-4]

for i in range(len(l)):

print(l[i], end =" ")

print()

# performing sum of natural

# number

sum = 0

for i in range(1, 10):

sum = sum + i

print(" random numbers :", sum)

\mathtt{\huge{\bf{\underline{\green{Output:-}}}}}

Function :- ()

[8,4,0,-4]

_______________________________________


Anonymous: Awesome! :)
Answered by SaI20065
17

  {\underline{\huge{\tt{Answer}}}}

 \tt{Python} \\ </p><p> \tt{ printing  \: a  \: number}\\ </p><p> \tt{for \:  i  \: in  \: range(10)} \\ </p><p> \tt{print(i, end =" ")} \\ </p><p> \tt{print()}

 \tt{using \:  range \:  for \:  iteration} \\ </p><p> \tt{l = \:  [8 \: ,4 \: ,0 \: ,-4]} \\ </p><p> \tt{for \:  i \:  in  \: range \: (len(l)):} \\ </p><p> \tt{print(l[i], end = \:  \: )} \\ </p><p> \tt{print()} \\ </p><p> \tt{ performing  \: sum  \: of  \: natural} \\ </p><p> \tt{ number} \\ </p><p> \tt{sum = 0} \\ </p><p> \tt{for \:  i \:  in  \: range(1, 10):} \\ </p><p> \tt{sum = sum + i} \\ </p><p> \tt{print(" random  \: numbers :", sum)} \\ </p><p>

Similar questions