OUTPUT :-
('x is ', 2)
('Return ', 2)
('The A is ', 2)
('x is ', 6)
('Return ', 3)
('x is ', 7)
('Return ', 100)
('The B is ', 103)
--------------------------------------XXXXXXXXXXXXXXXXXXXXXX-----------------------------------------------
program with explanation :-
"""
In this python function Fungsi(xx) function defines
which takes int value and returns int value
Fungsi() function count the appearence of parameter int no in the values array
and send back the count of this int no to the calling function
if the values array does not contain this parameter value the by default it sends 100.
output :-
Fungsi() function first prints parameter value then its returning value
and then calling function prints returing value.
"""
# Defines Fungsi() function
def Fungsi(xx):
# print parameter value on the console
print("x is ",xx)
#declaration of values array and count variable c
values = [8, 2, 6, 6, 2, 6]
c = 0
# Iterates over values array. len() function returns length of array
for i in range(len(values)):
# increment c if parameter value present in array value
if (values[i] == xx):
c = c+1
# It retruns value of c if c is greater than 0
if (c > 0):
print("Return ",c)
return c
# It retruns value of 100 if c is less than 0
else:
c = 100
print("Return ",c)
return c
# calls Fungsi() function with value 2 and store return value in A
A = Fungsi(2)
# print this value
print("The A is ",A)
# # calls Fungsi() function with values 6 and 7 and add those return values then store it in B
B = Fungsi(6) + Fungsi(7)
# print this value
print("The B is ",B)


5. What is the output of the below program? (14 marks) def Fungsi (xx): print ("x...
12. What is the output of this program? Your answer: 1 def main(): 2 print('The numbers are:') 3 for i in range (2,25): 4 isone (i) 5 def isone (number): isOne = True i = 2 while i < number and is one: if number % i == 0: 10 isOne = False 11 i += 1 Lou if isOne == True: 13 print("\t', i) 14 main() 12 13. What is the output of this program? Your answer: for i...
Consider the following small program. What will the output be? def foo(x): print(x) def bar(): return 3 def baz(y, z): return y * z a = bar() + 2 b = baz(a, 2) foo(a + b) 10 3 2 25 none of these 15
Please can I have a UML Class diagram for the Python program below: def main(): print() print("Welcome to Caesar Encryption and Viginere Decryption Cipher") print() print("Please select an option") option = "c" while option == "c": hello = input('Choose Caesar Cipher encrypt 1:\n' 'Choose Viginere Cipher Decrypt 2:\n') message = input('Enter a message: ') password = input('Enter a password: ') if hello == '1': viginere_cipher(message, password) elif hello == '2': viginere_cipher_decrypt(message, password) print() print("Choose an option") option = input('Enter c...
Consider the following small program. What will the output be? def foo(x): return x + 2 x = 1 x = foo(x) print(x) 'x' 3 1 2 none of these
I need to write a program based on two finished programs (listm.py and setunion.py) to implement the intersection operation between two sets of list. The program should not use the Python built-in list and set related functions and operations. I'm sorry about the program format is wrong(no "TAB" space), here is the same question I posted 2 days ago, but the question title is incorrect, there have complete images of my 3 Python program. The link is: https://www.chegg.com/homework-help/questions-and-answers/need-write-program-based-two-finished-programs-listmpy-setunionpy-implement-intersection-o-q44800953?trackid=uNY0ilRc Thank you!...
def average_word_length(string): num_words = 0 if not type(string)==str: return "Not a string" if not "A" or not "B" or not "C" or not "D" or not "E" or not "F" or not "G" or not "H" or not "I" or not "J"\ or not "K" or not "L" or not "M" or not "N" or not "O" or not "P" or not "Q" or not "R" or not "S" or not "T"\ or not "U" or not "V" or not...
VERSION 0000000 1 Question 14 [2.5 marks] What is the output of the following code fragment? value 0 for i in range (0, 25, 10) : print (value, end-" ") for j in range (0, 10, 5): value + 1 print ('final value', value ) (a) 0 2 4 final value 6 (b) 0 2 4 6 final value 8 (c) 0 3 6 final value 9 (d) 0 3 6 9 final value 12 (e) None of the above.
Consider the following Python program, where x is assumed to be a list of integers. def mystery_func(x): n = len(x) for i in range(n - 1): for j in range(i + 1, n): if x[j] - x[i] < j - i: return False return True 3a. In plain English, describe what it accomplishes (i.e., the relationship between input and output, not how the code works). 3b. Analyze the running time and express it with big O. 3c. Rewrite this function...
need help on all parts please and thank you
(e) What is the correct output of this code? (2 pts) >>> def func(x): >>> res = 0 >>> for i in range (len (x)): res i >>> return res >>> print (func(4)) ( 4 5 ) 6 ()7 ( What could be described as an immutable list? (2 pts) () a dimple ( ) a tuple ( ) a truffle () a dictionary (g) What is the result of the...
Im getting the same output but I'm assuming I'm forgetting to
incorporate the objective of evaluating in increments of 1 unit?
How do I code that?
Instructions from your Teacher: run tests Write a program that prints to three significant figures the values of f(x) from x = 0 to x = 10 in increments of 1 unit. The values of x include 0 and 10. The function f(x) is defined below.. 1 import math 2 # funtion g(x) returns...