 Lv 1116 points

# StrugglingStudent

• ### Python Help?

Define a function even_sum_odd_product(...)which receives a list lst of numbers as parameter, and returns a list result such that at the even positions i, result contains the sum of all numbers in lst up to position i, and at all odd positions contains the product of all numbers up to position i.

For example, for the list [1,2,3,4,5], the function should return the list [1,2,6,24,15], because

1 = 1

1*2 = 2

1+2+3 = 6

1*2*3*4 = 24

1+2+3+4+5 = 15

As an example, the following code fragment:

print(even_sum_odd_product([1,2,3,4,5]))

should produce the output:

[1, 2, 6, 24, 15]

1 AnswerProgramming & Design7 months ago
• ### Python help?

Define a function count_hops_to_last(...) that receives a non-empty list lst of non-negative integers as parameter, and returns the number of "hops" it takes to get from the first to the last position in the list.

The list lst will have values which are numbers between 0 and len(lst)-1 (inclusive). Those values can be understood as positions/indices in lst, in any order. For example possible lists coming into the function could be [1,3,0,2] and [7,6,1,10,9,5,3,2,0,8,4].

A "hop" means moving from position i to another position, which is the value at position i in lst. "The hopping" starts happening always at position 0 and will end in the last position. This function should return the number of hops that were needed to go from the first position to the last.

In the list [7,6,1,10,9,5,3,2,0,8,4] , it takes six hops to reach the last position from the first position:

0->7->2->1->6->3->10

You can assume that the input list lst does not contain any cycles. For example, the list [1,0,2] is not allowed (and therefore it will not be a test case) as it would result in an infinite chain of hops:

0->1->0->1->0->1->...

As an example, the following code fragment:

print(count_hops_to_last([1,3,0,2]))

should produce the output:

2

1 AnswerProgramming & Design7 months ago
• ### Python help?

Define a function named last_position_disagree(...) which receives as parameter two strings str1 and str2 of the same length, consisting only of letters, and returns the last position where the two strings have different letters. Upper case and lower case versions of the same letter are treated as being identical. If there is no such position, the value -1 should be returned. Hint: Consider visiting the strings backwards.

As an example, the following code fragment:

str1 = "hallo"

str2 = "hxlxo"

print(last_position_disagree(str1,str2))

should produce the output:

3

1 AnswerProgramming & Design7 months ago
• ### Python Help?

Define a function named multiples(...) which receives as input two non-negative integers: number and howmany, and returns a list with howmany multiples of the number number, in increasing order.

As an example, the following code fragment:

print(multiples(6,4))

should produce the output:

[6, 12, 18, 24]

• ### Python Coding Help?

Define a function immPairsBool(..) which receives a string (containing letters, digits or special characters) and returns the Boolean value True if there are at least two identical characters one immediately after the other in the string.

As an example, the following code fragment:

val = immPairsBool("123xx321")

print (val)

should produce the output:

True

• ### Python Coding Question?

(BONUS) Define a function named ayWords(...) which receives a list (origlist) that contains words (in lower or upper case) and returns a new list containing corresponding new words as follows. (if the original list is empty the returned list should be empty)

a) Letters in the new word will only be in lower case.

b) To obtain a new word you should 'remove' the first letter in the original word and place that letter at the end of the original word.

For example the (partial) new word for 'BEst' would be 'estb'.

c) Further, if that first letter placed at the end is a vowel, you should further add to the new word the letter 'y'. If instead, the letter that was placed at the end is a consonant, then add the letters 'ay' to the new word. Recall that "a','e','i','o','u' are vowels, other letters are consonants.

For example, the new word for 'BEst' would be 'estbay', and the new word for 'oH' would be 'hoy'

d) Finally, if the word is in an odd position in the original list then the new word would have attached at the end its position number.

For example

ayWords( ['I','FEel','the','BEst'] ) should return ['iy', 'eelfay1', 'hetay', 'estbay3']

As an example, the following code fragment:

print(ayWords( ['I','FEel','the','BEst'] ) )

should produce the output:

['iy', 'eelfay1', 'hetay', 'estbay3']

1 AnswerProgramming & Design7 months ago
• ### Python Coding Question?

(PART B) Define a function num_char_string(...) which receives a list as parameter whose elements alternate between non-negative numbers and characters, beginning with a number, and ending with a character. The function should return a string that consists of sequences of characters repeated as many times as the preceding number in the list.

For example, when calling the function with the list [3,"a",4,"b"] the function should return the string 'aaabbbb' (three a's, followed by four b's).

As another example, when calling the function with the list [1,"H",0,"X",1,"i",5,"!"] the function should return the string 'Hi!!!!!'

As an example, the following code fragment:

lst = [3,"a",4,"b"]

res = num_char_string(lst)

print(res)

should produce the output:

aaabbbb

1 AnswerProgramming & Design7 months ago
• ### Molar Mass help?

8.442 g of a non-volatile solute is dissolved in 325.0 g of water.

The solute does not react with water nor dissociate in solution.

Assume that the resulting solution displays ideal Raoult's law behaviour.

At 70°C the vapour pressure of the solution is 230.93 torr.

The vapour pressure of pure water at 70°C is 233.70 torr.

Calculate the molar mass of the solute (g/mol).

Now suppose, instead, that 8.442 g of a volatile solute is dissolved in 325.0 g of water.

This solute also does not react with water nor dissociate in solution.

The pure solute displays, at 70°C, a vapour pressure of 23.37 torr.

Again, assume an ideal solution.

If, at 70°C the vapour pressure of this solution is also 230.93 torr.

Calculate the molar mass of this volatile solute.

Chemistry11 months ago
• ### Molecular formula Help?

An unidentified covalent molecular compound contains only carbon, hydrogen, and oxygen. When 7.20 mg of this compound is burned, 17.32 mg of CO2 and 2.03 mg of H2O are produced.

The freezing point of camphor is lowered by 26.4°C when 2.410 g of the compound is dissolved in 14.25 g of camphor (Kf = 40.0°C kg/mol).

What is the molecular formula of the unidentified compound?

Choose appropriate coefficients in the molecular formula below.

C#  H#  O#

Chemistry11 months ago
• ### Help with a Clausius - Clapeyron Question?

The vapour pressure of a pure substance at various temperatures is presented below.

T (°C) Pvap (mmHg)

0.0 16.5

15.0 32.1

25.0 48.2

40.0 84.4

60.0 164.7

80.0 298.0

Calculate DeltaH°vap for this substance and normal boiling point