Q. Start with the list [8, 9, 10]. Do the following using list functions:
(a) Set the second entry (index 1) to 17
(b) Add 4, 5 and 6 to the end of the list
(c) Remove the first entry from the list
(d) Sort the list
(e) Double the list
(f) Insert 25 at index 3
You can understand by Watching video :-
Answer =
(a)l. insert(2,17)
(b) l. extend([4,5,6])
(c) l. pop(0)
(d) l. sort()
(e) l. extend(l)
(f) l. insert(3, 25)
dgdg
ReplyDelete??????
Deletehow code this in python?
ReplyDeletewrite
Deletel. insert(2,17)
l. append(4,5,6)
l. pop(0)
l. sort()
l. extend(l)
l. insert(3,25)
in python directly .
L
ReplyDelete???????????
DeleteTttttttt
ReplyDeleteWelcome : )
DeleteQ.2. Find the output:
ReplyDeleteA = [11, 22, 33, 44, 55]
print( A [3 :0: -1]
[44, 33, 22]
Deletecan you give me the answer for this Question
ReplyDelete1. Write a program that asks the user to enter a list of integers. Do the following:
(a) Print the total number of items in the list.
(b) Print the last item in the list.
(c) Print the list in reverse order.
(d) Print Yes if the list contains a 5 and No otherwise.
(e) Print the number of fives in the list.
(f) Remove the first and last items from the list, sort the remaining items, and print the
result.
lst = eval(input("Enter a List of Number :-"))
Delete#a
print(len(lst))
#b
print( lst [-1])
#c
print(lst [ ::-1])
#d
if 5 in lst :
print("Yes")
else :
print("NO")
#e
print(lst.count(5))
#f
lst.pop(0)
lst.pop(-1)
lst.sort()
print(lst)
: )
is it possible for someone to help me out with these two questions please? :(
ReplyDeleteQuestion 2 (25 Marks)
Write a program that generates a list of 20 random numbers between 1 and 100.
(a) Print the list.
(b) Print the average of the elements in the list.
(c) Print the largest and smallest values in the list.
(d) Print the second largest and second smallest entries in the list
(e) Print how many even numbers are in the list.
When playing games where you have to roll two dice, it is nice to know the odds of each
roll. For instance, the odds of rolling a 12 are about 3%, and the odds of rolling a 7 are about
17%. You can compute these mathematically, but if you don’t know the math, you can write
a program to do it. To do this, your program should simulate rolling two dice about 10,000
times and compute and print out the percentage of rolls that come out to be 2, 3, 4, . . . , 12.
import random
Deleterandom_numbers = random.sample(range(1, 100), 20)
print(random_numbers)
print("The average of the list is:", sum(random_numbers) /len(random_numbers))
print("The largest number in the list is:", max(random_numbers))
print("The smallest number in the list is:", min(random_numbers))
print("The second largest number is:", sorted(random_numbers, reverse=True)[1])
print("The second smallest number is:", sorted(random_numbers, reverse=True)[-2])
even_count = 0
for num in random_numbers:
if num % 2 == 0:
even_count += 1
print("The count of the even numbers in the list is:", even_count)
This is wrong
Deletehow code this in C?
ReplyDeleteThanks
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )