hey can somebody help me with these? 5.Assign True to the variable has_dups if t
ID: 3529091 • Letter: H
Question
hey can somebody help me with these? 5.Assign True to the variable has_dups if the string s1 has any duplicate character (that is if any character appears more than once) and False otherwise 6.Assume that c is a variable that has assigned a string value. Write an expression whose value is true if and only if c is a newline character. 7. Write a sequence of statements that finds the first comma in the string associated with the variable line , and associates the variable clause the portion of line up to, but not including the comma. 8.Write an expression whose value is the result of converting the int value 42 to a str (consisting of the digit 4 followed by the digit 2). 9.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" . 10.Write an expression whose value is the arithmetic sum of the int associated with x , and the all-digit str associated with s . (Hint: you will need to convert the str to an int .) 11. Write a statement to set the value of the variable popStr to a string representation of the value referenced by the variable pop . 12.Assume the variable date has been set to a string value of the form mm/dd/yyyy, for example 09/08/2010. (Actual numbers would appear in the string.) Write a statement to assign to a variable named dayStr the characters in date that contain the day. Then set a variable day to the integer value corresponding to the two digits in dayStr . i can it seems alot but im having alot of trouble with it. I would appreciate help on ay of these.Explanation / Answer
what, exactly, is the question? I can mention that the code for 2 is wrong, though. It is simpler to set the flag to False first, and then just set it to True every time you find a duplicate character. Your code flip-flops between True and False.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.