Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python please! Will thumbs up! 1. Create a list L with L=[1,2,3,,100] (all the numbers from 1 to 100 ). What is L[50] ? 2.
Python please! Will thumbs up!
1. Create a list L with L=[1,2,3,,100] (all the numbers from 1 to 100 ). What is L[50] ? 2. Take the same list L, and extract a slice of the form [5,10,15,,95] with a command of the form L[a:b:c]. 3. Take the same list L, and change all the even numbers to zeros, so that L looks like [1,0,3,0,5,0,,99,0]. Hint: You might wish to use the list [0]50. 4. Try the command L[1::1] on a list. What does it do? Can you guess before executing it? Can you understand why? In fact, strings are indexed like lists. Try setting L=He11o ' and the previous command. 5. Create the list [1,100,3,98,5,96,,99,2], where the odd terms are in order and the even terms are in reverse order. There are multiple methods! 6. Use the append method with a loop to create a list of perfect squares, [0,1,4,9,16,25,,10000]. 7. Create a list of 52 "cards" to resemble a standard card deck. The suits can be denoted C,S,D,H for clubs, spades, diamonds, and hearts. The numbers can be denoted 1-13 (with Ace = 1, Jack =11, Queen =12, King = 13). So " 9H " would be the 9 of hearts, and 12S the queen of spades. Your list L should contain every card. 8. Challenge: write a function which performs a "perfect riffle shuffle" on a list of cards. This shuffle should have the effect of dividing the deck into two equal pieces, and then precisely interlacing the two pieces to form a new list. E.g., an input list of [1,2,3,4,5,6] should be broken into [1,2,3] and [4,5,6] and then interlaced as [1,4,2,5,3,6]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started