Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is for my computer science class, where we are learning about python. 2.12 Write Python expressions corresponding to these statements: (a) The sum of
This is for my computer science class, where we are learning about python.
2.12 Write Python expressions corresponding to these statements: (a) The sum of the first seven positive integers (b) The average age of Sara (age 65), Fatima (57), and Mark (age 45) (c) 2 to the 20th power (d) The number of times 61 goes into 4356 (e) The remainder when 4365 is divided by 61 2.13 Start by evaluating, in the interactive shell, the assignment: >>> s1 - >>> s2 = + Now write string expressions involving s1 and s2 and string operators + and that evaluate (a) '-+! (b) '-+! (d) '+--+--' (e) +--+--+-- --+-- --+-- ---- --+! (1) ++-+++--+-+++--+-+++--+-+++--+-+ +--! Try to make your string expressions as succinct as you can. 2.14 Start by running, in the shell, the following assignment statement: >>> S = 'abcdefghijklmnopqrstuvwxyz' Now write expressions using string s and the indexing operator that evaluate to 'a', 'c', 'z', 'y', and 'q! 2.15 Start by executing s = 'goodbye Then write a Boolean expression that check whether: (a) The first character of string s is 'g' (b) The seventh character of s is g (c) The first two characters of s are g and a (d) The next to last character of s is x (e) The midle character of s is d (1) The first and last characters of strings are equal (8) The last 4 characters of string s match the string 'tion! Note: These seven statements should evaluate to True, False, False, False, True, False, and False, respectivelyStep 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