in python
str = 'aaabccpppp'
need a out put like this:
a:3
b:1
c:2
p:4
#use python 3 IDLE
#editable code is given below,
but to maintain indentation please refer image of code
from collections import Counter
str = 'aaabccpppp'
y=str
# str is a built in function.it should not be use as a variable
name
#delete str
del str
d=Counter(y)
for k,v in sorted(d.items()):
print(k+":"+str(v))
in python str = 'aaabccpppp' need a out put like this: a:3 b:1 c:2 p:4
Python Given a list like myList = [1, 2, 3, 4]. Your task is to find sum of each number with another number. For example, 1+2+1+3+1+4,2+3,2+4,3+4. Use for loop to accomplish this task. Return Output: 1 + 2 1 + 3 1 + 4 2 + 3 2 + 4 3 + 4 The sum value: 30
Python 3 Monster = {"name": str, "kind": str, "spookiness": int, "undead?": bool} ''' M5. Define a function `count_spooky_monsters` that consumes a list of monsters and produces an integer indicating how many monsters have a spookiness of 2 or more. ''' ''' M6. Define the function `count_vampires` that consumes a list of monsters and produces an integer indicating how many monsters are of the kind "vampire". '''
Page 3 of 7 (Python) For each substring in the input string t that matches the regular expression r, the method call re. aub (r, o, t) substitutes the matching substring with the string a. Wwhat is the output? import re print (re.aub (r"l+\d+ " , "$, "be+345jk3726-45+9xyz")) a. "be$jk3726-455xyz" c. "bejkxyz" 9. b. "be$jks-$$xyz" d. $$$" A object a- A (2) 10. (Python) What is the output? # Source code file: A.py class A init (self, the x): self.x-...
python List1=[ ["a", 1], ["b", 3], ["c", 3], ["d", 2], ["e", 1], ["f", 4], ["g", 2]] 1 def function(Letter,List),example, function("c",List) return 3 2 def function(word,List),example, function("a",List) return 1, function("be",List) return 4, function("bee",[b,5],[e,20]) return 45 Dictionary = ["a","bee","ad","ae"] 3 ["a","b","y","e"] return[["a",1],["ae",2],["bee",5]] 4 input a list, find largest value words can spell, return words and value dont using loop, using recursion for those code
IN PYTHON 3 LANGUAGE, please help with function, USE RECURSION ONLY def im(l: 'an int, str,list,tuple,set,or dict') -> 'an int, str, tuple, or frozenset' pass SAMPLE OUTPUT: The following call (with many mutable data structures) imm(1) returns 1 imm('a') returns 'a' imm( (1, 2, 3)) returns (1, 2, 3) imm( frozenset([1, 2, 3])) returns frozenset({1, 2, 3}) imm( [1, 2, 3, 4, 5, 6]) returns (1, 2, 3, 4, 5, 6) imm( [1, 2, [3, [4], 5], 6]) ...
Python 3, fill out the table (just type)
Fill in the table below just like you did in last week's lab. For each expression, we would like you to first compute the expression in your head, without Python. You should that down in the second column, or "" if you have no idea. Next you should use Python to compute the expression. If the answers are different, try to explain why in the last column. Expected Calculated Reason for Expression...
ONLY need help with C out of part 6, and need help with B out of
Part 4. Thank you! ☺️
H2O _Mg(OH)2 + __HPO4 → _Mg 3(PO4)2 + In the reaction above (Mg = 24.31; O = 16.00; H = 1.01; P = 30.97) a) 3.498 x 100 g of H Po, will require how many moles of Mg(OH)2? b) 3.498 x 10° g of H3PO, will produce how many molecules of Mg 3(PO4)2? c) 3.498 x 100 g...
1. Consider the following code segment. String str = "AP"; str += "CS " + 1 + 2; System.out.println(str); What is printed as a result of executing the code segment? A: CS AP12 B: AP CS3 C: CSAP 12 D: APCS 12 E: APCS 3 2. Consider the following code segment. String dessert = "pie"; dessert += "straw" + dessert + "berry"; What is the value of dessert after the code segment has been executed? A: strawpieberry B: piestrawpieberry C:...
hi I need to understand how the out put become -4 in first question and out put 310 for the second question please can you explain to me thanks a lot 1.(ch12. Sc16. P. 820. loop) Consider the following code: import java.util.*; public class MyLoopOneSGTest{ public static void main(String[] args){ int w = 3; System.out.println(myLoop(w)); } public static int myLoop(int n){ int x = 1; for (int i = 1; i < n; i++){ x = x - i; }...
2,Let X be a Poisson (mean-5) and Let Ybe a Poisson (mean-4). Let Z-X+Y.Find P(X-312-6) Assume X and Y are independent. 1 like to see answers for P(A), (B), P(AB), and and hence P(A B). Here A You can work out the probabilities (P(A).P(B),P(AB), and P(AIB) using your calculator, or Minitab or Mathematica. I dont need to see your commands.I just like to see the answers for the probabilities of ABABAIB You do item 1 lf your FSU id ends...