# write an expression whose value is the last character in the str associated with s.

Get help with your computer science assignments and homework from certified Gudwriter tutors. Upload your assignment now and get started!

### Elevate Your Writing with Our Free Writing Tools!

Did you know that we provide a free essay and speech generator, plagiarism checker, summarizer, paraphraser, and other writing tools for free?

Access Free Writing ToolsA few problems from a CS homework due tonight!

Please help! Using Python 3.4

**1. Write an expression whose value is the result of converting the str value associated with s to an int value. So if s were associated with “41” then the resulting int would be 41.**

**Answer; **int(s)

**2. Write an expression whose value is the last character in the str associated with s.**

**Answer; **s[-1]

**3. Given variables first and last, each of which is associated with a str, representing a first and a last name, respectively. Write an expression whose value is a str that is a full name of the form “Last, First”. So, if first were associated with “alan” and last with “turing”, then your expression would be “Turing,Alan”. (Note the capitalization! Note: no spaces!) And if first and last were “Florean” and “fortescue” respectively, then your expression’s value would be “Fortescue,Florean”.**

**Answer;**

# Codelab 50773 # Given variables first and last, each of which is associated with a str, # representing a first and a last name, respectively. Write an expression whose # value is a str that is a full name of the form "Last, First". # So, if first were associated with "alan" and last with "turing", # then your expression would be "Turing,Alan". ( # Note the capitalization! Note: no spaces!) # And if first and last were "Florean" and "fortescue" respectively, # then your expression's value would be "Fortescue,Florean". first = 'aLaN' last = 'tuRING' last.capitalize() + "," + first.capitalize() # Codelab 50250 # Assume there is a variable h already associated with a positive integer value. # Write the code necessary to compute the sum of the first h perfect squares, # starting with 1. # (A perfect square is an integer like 9, 16, 25, 36 that is equal to the # square of another integer (in this case 3*3, 4*4, 5*5, 6*6 respectively).) # Associate the sum you compute with the variable q. # For example, if h is 4, you would assign 30 to q because the first # 4 perfect squares (starting with 1) are: 1, 4, 9, 16 and 30==1+4+9+16. h = 4 q = 0 for k in range(1, h + 1): q = q + k**2 # Codelab 50177 # Given a variable n refers to a positive int value, # use two additional variables , k and total to write a for loop to # compute the sum of the cubes of the first n counting numbers, # and store this value in total. # Thus your code should put 1*1*1 + 2*2*2 + 3*3*3 +... + n*n*n # into total. Use no variables other than n, k, and total. n = 3 total = 0 for k in range(1,n+1): total = total + k**3 from graphics import * Win = GraphWin("CSI", 600, 400) Win.setCoords(0, 0, 60, 40) # Other reasonable coordinates: #W.setCoords(0, 0, 600, 400) #W.setCoords(0, 0, 6, 4) P = Point(60, 40) C1 = Circle(Point(30,20), 10) C2 = Circle(P, 20) C1.draw(Win) C2.draw(Win) from graphics import * Win = GraphWin("CSI", 600, 400) Win.setCoords(0, 0, 60, 40) shape = Circle(Point(30,20), 10) shape.setFill('red') shape.draw(Win) for i in range(10): p = Win.getMouse() c = shape.getCenter() dx = p.getX() - c.getX() dy = p.getY() - c.getY() shape.move(dx, dy) Win.close()

**4. Write an expression whose value is the result of converting the int value associated with x to a str. So if 582 was the int associated with x you would be converting it to the str “582”.**

**Answer; **str(x)

**5. Write an expression whose value is the str consisting of all the characters (starting with the sixth) of the str associated with s.**

**Answer; **s[5:]

Special offer! Get 20% discount on your first order. Promo code: SAVE20