Write a function createPassword() with no return value to randomly select 8 capital letters from the alphabet. The function receives the address of the first characters of the password string as parameter. Hint: Declare a characters string that contains all the capital letters of the alphabet and use the index values of the characters in the string for random selection of charac
Q: Write a function countNonAlnum() that takes a string as parameter, finds and returns the number of…
A: Python offers built in method isalnum() which returns true is string is alphabet or numeric
Q: 1- Write a function that takes a word less than 25 characters long and returns the letter that word…
A: #include <stdio.h> #include <string.h> #include <ctype.h> // returns the first…
Q: Write a function called isVowel that receives one parameter as character and returns true if it is a…
A: Program: // include header files. #include <iostream> using namespace std; //function which…
Q: Write a function combine(names, ages) that takes in two lists, names and ages and returns a list of…
A: The program requires combining two lists in the form of key-value pairs where the first list the key…
Q: Write a function named count_letters that takes as a parameter a string and returns a dictionary…
A: def countletters(k): freq = {} for items in k: if (ord(items)>=65 and…
Q: Write a function, insertAt, that takes four parameters: an array of integers, the number of elements…
A: Program code: #include<iostream> using namespace std; int insertAt(int list[],int size,int…
Q: Write a function to replace all instances of character c1 with character c2 and vice versa. Examples…
A: Algorithm - Create a method with name doubleSwap with three argument. Loop over the string…
Q: In Programming Exercise 13 (Chapter 8), you are asked to write a program to calculate students’…
A: ANSWER:-
Q: Write the following function to check whether string s1 is a substring of string s2. The function…
A: Program: // C++ version 14#include <iostream>#include <cstring>using namespace std; //…
Q: Given two dictionaries d1 and d2, write a function combine_dict(d1, d2), which return a new…
A: Python code to perform the rule for combine dictionary is given below, hope you like it.
Q: Please answer it in Python write a function word_vers_dictionary(word), which takes a word…
A: According to company guidelines we are supposed to answer only one question. Kindly repost other…
Q: Write a function MedianWithoutHL(ScoreList) that takes an unsorted list of n numbers as a parameter,…
A: Explanation Step by step algorithm create an array of double and fill the array with user…
Q: Write ONLY a function, findLetter, that receives a string, str, and a character, ch, as arguments…
A: Function findLetter can be defined with int return type. For loop is used to find the first…
Q: Write a function in python, cannot use isalpha or .get named count_letters that takes as a parameter…
A: I give the code in Python along with output and code screenshot
Q: Write a function findMyCampsites . Given a campgrounds array, a type of view as a string, and the…
A: Solution: Now we can add the condition for the pageSize and isReserved: code: let campgrounds = [ {…
Q: Write a function called myFind which accepts a 2 strings as parameters (tmp and strToFind) and…
A: Code: def main(): print(myFind("welocmetobartleby","bartle")) #myFind method will take the…
Q: In the cell below, there is a function that is not operating as anticipated. count_consonants is…
A: def Check_Vow(string): # casefold has been used to ignore cases string = string.casefold()…
Q: Write a function convert_to_millimetres (measurements) which takes a list of measurements in…
A: Here I have created a function and inside the function, I have used a for loop to iterate over the…
Q: Write a function createPassword() with no return value to randomly select 8 capital letters from the…
A: The required C++ code is: #include<iostream>#include<cstdlib>#include<time.h>using…
Q: Write a function that takes as argument two lists both with the same number of elements, where each…
A: import numpy as np def mergelst(lst1, lst2): return np.array([[i, j] for i, j in zip(lst1*2,…
Q: We will create a function ( avg_sentence_len ) to calculate the average sentence length across a…
A: Required:
Q: Write a function verifsort that accepts a list as a parameter, check if the list elements are sorted…
A: #include <iostream>using namespace std; int verifsort(int arr[]){ /* If list is in…
Q: Write a function in C++ "replaceVowels()" with no return value to replace all the vowels (A, E, I,…
A: The, code has given below;
Q: Write a function findFirstSpace() that takes a string as parameter, finds and returns the index of…
A: Since you have not mentioned programing language I'm doing this in python. Please make sure code…
Q: Below is a bubble_up function that takes 3 parameters: the list, a start index, and an end index,…
A: Below is a bubble_up function that takes 3 parameters : the list ,a start index and an end…
Q: We will create a function ( avg_sentence_len ) to calculate the average sentence length across a…
A: Required
Q: Write a function decode_string() that gets a string as a parameter -so called encrypted string-,…
A: Part4: Algorithm: Start Read a string Initialize the dictionary with given data Initialize an empty…
Q: Write a function called "reverse" that accepts a dictionary as a parameter and returns a dictionary…
A: def reverse(Dict): print("Input dictionary : ") print(Dict) rDict={} for key, value in…
Q: Write a function named count_letters that takes as a parameter a string and returns a dictionary…
A: Given: Write a function named count_letters that takes as a parameter a string and returns a…
Q: Write a function is Prime (a_nNum) that takes a positive integer as an argument and returns True if…
A: Here is the python code. See below step for code and output:
Q: Write a function called subsequence() that finds the longest common subsequence of two DNA strands.…
A: Program explanation: Declare the header files Declare and define the function to calculate the…
Q: Create a function that takes an unsorted list of numbers and returns the number of unique triplets…
A: function tripletSum(lst, n) { let sets = new Set(); lst.sort((a, b) => a - b); for (let i = 0; i…
Q: Write a function createPassword() with no return value to randomly select 8 capital letters from the…
A: Program Explanation: The header file “<iostream>” is declared that contains all standard…
Q: Write a function called number_matrix (r,c) that takes two parameters r and c and PRINTS ON THE…
A: The matrix is a rectangular arrangement of numbers or data. In a matrix, the horizontal entries…
Q: function compute_stats, such that given a string of grades as an input parameter, it calls the…
A: Code: def get_new_grades(x): res=0 for i in x: res+=i return…
Q: Write a function longestRun($str) that takes a string as a parameter and returns the length of the…
A: The answer is
Q: Write a function that takes the number n, which reverses the binary representation of that number,…
A: Giving the solution in Java Script Code function reversedBinaryInteger(num) { let bin =…
Q: Write a function that takes a dictionary representing points in 3D space and an associated color for…
A: #function that takes a dictionary of points in 3D space and an associated color for each point#and…
Q: Write a function named count_letters that takes as a parameter a string and returns a dictionary…
A: Given:-
Q: 1- Write a function that takes a word less than 25 characters long and returns the letter that word…
A: To find the capital letter of a word, we can test it against the ASCII values. We know that the…
Q: Complete the below function which takes an integer k and a string s as its arguments and returns a…
A: The program takes two inputs from the user such as integer value of k and string s. k is the int…
Q: Write a C++ function, lastLargestIndex, that takes as parameters an int array and its size and…
A: Given: Write a C++ function, lastLargestIndex, that takes as parameters an int array and its size…
Q: Write a function named addCommas that accepts a string representing a number and returns a ew string…
A: #include "strings.h"std::string addCommas(std::string const &s){ std::string str = s; int…
Q: Write a Python function, namely PasswordVerfication(pwdList), which takes a list of passwords. The…
A: Python Code for Above : #validity of each password def isValid( str ): lowercase, uppercase,…
Q: Write a function load_metrics(filename) that given filename (a string, always a csv file with same…
A: Please upvote. I am providing you the correct answer below. Please please please.
Q: Write a function called number_matrix(r,c) that takes two parameters r and c and PRINTS ON THE…
A: #include <stdio.h> void number_matrix(int r, int c){ int i = 1; int j = 1; int k = 1;…
Q: Create the function that takes a list of dictionaries and returns the sum of people's budgets.…
A: Define a get_budgets function Initialise a counter Loop inside the dictionary to retrieve the budget…
Write a function createPassword() with no return value to randomly select 8 capital letters from the alphabet.
The function receives the address of the first characters of the password string as parameter.
Hint: Declare a characters string that contains all the capital letters of the alphabet and use the index values
of the characters in the string for random selection of characters, e.g.
Step by step
Solved in 3 steps with 1 images
- Write a function inde which returns the index (start from 1) of the occurrence of a given value. Use helper function. Two functions are enough.inde(1, [1,2,1,1,2,2,1]) → [1,3,4,7] Write a function nele which repeats each element in a list n times. Use helper function. Two functions only.nele([1,2],3) → [1,1,1,2,2,2] Write a function isfact to determine if a positive integer is a factorial number. Do not use any formula such as T(n)=n(n+1)/2. Do it in recursive fashion. Two functions are enough.isfact(120) → true18) Write a function that takes in 2 lists and checks whether they have the same elements in the same order. If the elements are all the same, the function should return the string “same”. If any of the elements are different, the function should return the string “different”. The definition of the function should be: Def equals(a, b):Write the following function that sorts and merges two lists into a new sorted list. The new list contains only even numbers. def myMergeEvenList(list1, list2): Enter list1: 10,5,6,7 Enter list2: 12,8,5,0,1 The merged list is: 0,6,8,10,12
- Suppose we use a Python dictionary to store gradebooks of multiple courses. gradebooks = {'Course 1': [['Troy', 92], ['Alice', 95]], 'Course 2': [['James', 89], ['Charles', 100], ['Bryn', 59]], 'Course 3': [['Jack', 74], ['Karren', 97], ['Astha', 92], ['Nancy', 96]]} Use the builtin sorted function with appropriate programming constructs (e.g., lambdas, comprehensions, , etc.) to complete the following tasks: Write code to create a new list named gradebooks_a, with students of each course being sorted by score in descending order. The expected result is: [[['Alice', 95], ['Troy', 92]], [['Charles', 100], ['James', 89], ['Bryn', 59]], [['Karren', 97], ['Nancy', 96], ['Astha', 92], ['Jack', 74]]]Instructions are given within the quotations for each function. 1)def remove_duplicate_sorted(t): """ this function returns a new list generated from t that has t's elements without duplicates and is sorted from smallest to largest. """ return [] 2)def list_to_dictionary(t): """ t is a list of values (values could be str, list, tuple, set, dictionary), create and return a dictionary such that the key is len(v) for some v in t, and the value is a list of values [v1, v2, ...] from t (in the order they appeared in t) whose len(vi) is the key. for example: if t = [(1,2,3), "abc", [1, 2], (), ""] then return value of this function should be: {3: [(1, 2, 3), 'abc'], 2: [[1, 2]], 0: [(), '']} """ return {} 3)def run(): """ This function repeatedly ask user to enter a string and store them in a list and print it out. It also passes this list to remove_duplicate_sorted() function and list_to_dictionary() function and print out the results of the function calls. """ return if __name__ ==…Write a user defined function named as “length_list” function that finds the length of a list of list_node_t nodes. This code should fit with the following code.Partial Code: #include <stdio.h> #include <stdlib.h> /* gives access to malloc */ #define SENT -1 typedef struct list_node_s { int digit; struct list_node_s *restp; } list_node_t; list_node_t *get_list(void); int main(void) { list_node_t *x;int y; x=get_list(); printf("%d\n",x->digit); printf("%d\n",x->restp->digit); printf("%d\n",x->restp->restp->digit); // your length_list function should be called from here printf("Length is: %d",y); } /* * Forms a linked list of an input list of integers * terminated by SENT */ list_node_t * get_list(void) { int data; list_node_t *ansp; [20]scanf("%d", &data); if (data == SENT) { ansp = NULL; } else { ansp = (list_node_t *)malloc(sizeof (list_node_t)); ansp->digit = data; ansp->restp = get_list(); } return (ansp);
- Use the following code which adds and prints elements of a simply linked list, and add a member function that will duplicate nonzero value nodes in a list. Call your function properly in main and print the list again. #include <iostream> using namespace std; struct node { int data; node *next; node(int d,node*n=0) { data=d; next=n; } }; class list { node *head; public: list() { head=0; } void print() { for (node *t=head;t!=0;t=t->next) cout<<t->data<<" "; cout<<endl; } void add(int el) { head=new node(el,head); } }; void main() { list l; l.add(0); l.add(7); l.add(1); l.add(0); l.add(3); l.print(); }Q1:Write a function that returns a new list by eliminating theduplicate values in the list. Use the following function header:def eliminateDuplicates(lst):Write a test program that reads in a list of integers, invokes the function,and displays the result. Here is the sample run of the program Enter ten numbers: 2 3 2 1 6 3 4 5 2The distinct numbers are: 1 2 3 6 4 5 Q2:Write a program that reads in your Q1 Pythonsource code file and counts the occurrence of each keyword in the file.Your program should prompt the user to enter the Python source code filename. This is the Q1: code: def eliminateDuplictes(lst):newlist = [] search = set() for i in lst: if i not in search: newlist.append(i) search.add(i) return newlist a=[] n= int(input("Enter the Size of the list:")) for x in range(n):item=input("\nEnter element " + str(x+1) + ":") a.append(item) result = eliminateDuplictes(a) print('\nThe distinct numbers are: ',"%s" % (' '.join(result)))Define the function (siftNum lst). This function should resolve to all the numbers in the list, lst. For example: (siftNum '(a 8 2 1 m l 90 p 2)) resolves to '(8 2 1 1 90 2).
- Use the following code which adds, searches and prints elements of a doubly linked list, and add a member function that will union 2 doubly linked lists and store the union elements in a new list. Call your function properly in main and print all 3 lists. Note: You can consider that each list is a set, where no redundant elements are found. #include <iostream> using namespace std; struct node { int data; node *next,*prev; node(int d,node*n=0,node *p=0) { data=d; next=n; prev=p; } }; class list { node *head; public: list() { head=0; } void print() { for (node *t=head;t!=0;t=t->next) cout<<t->data<<" "; cout<<endl; } bool search(int el) { for (node *t=head;t!=0;t=t->next) if(t->data==el) return true; return false; } void add(int el) { if(head==0) head=new node(el); else { node *t=head; for(;t->next!=0;t=t->next); t->next=new node(el,0,t); } } }; void main() { list l1,l2,l3; l1.add(0); l1.add(7);…C++ Create a generic function add_bookends(ls, e) that adds a copy of element e to the front and back of list ls.# Create a list of tuplestuples = [("p", 1), ("q", 2), ("r", 3)]# Use enumerate() to iterate over the tuples and print the index and valuefor index, value in enumerate(tuples):print(index, value)This code will print the following output:0 p1 q2 r Could you try to modify your code to get the output mentioned by you? Also, the output for the above function should be0 ('p', 1)1 ('q', 2)2 ('r', 3) Could you please confirm?