1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tia_tia [17]
3 years ago
13

Complete the function binary_strings(string: str) -> Generator[str, None, None]. binary_strings accepts a string of 0's, 1's,

and X's and returns a generator that goes through all possible strings where the X's could be either 0's or 1's. For example with the string '0XX1', the possible strings are '0001', '0011' '0101', and '0111'. When generating the strings, the X's should first be replaced with 0's and then be replaced with 1's. Requirements You may NOT use anything from the itertools or functools modules You must use the yield keyword in your solution to receive credit To receive credit, you must use recursion in this problem. binary_strings does not itself need to be recursive but you must use recursion in your solution
Computers and Technology
1 answer:
mixer [17]3 years ago
6 0

Answer:

A python program was used for this given question to complete  the function binary_strings(string: str) -> Generator[str, None, None].

binary_strings accepts a string of 0's, 1's, and X's and returns a generator that goes through all possible strings where the X's could be either 0's or 1's

Explanation:

Solution:

PYTHON CODE:

def binary_strings(string):

binary_string = list(string) # Converting To List

Generator(binary_string,0) # Calling The Recursive Generator Function

''' Recursive Function To Generate All Binary Strings

Formed By Replacing Each 'X' Character By 0 Or 1 '''

def Generator(binary_string,index):

if index == len(binary_string):

print(''.join(binary_string))

return

if binary_string[index] == "X":

# Replace 'X' By '0' And Call Recursively For Next Index

binary_string[index] = '0'

Generator(binary_string, index + 1)

# Replace 'X' By '1' And Call Recursively For Next Index

binary_string[index] = '1'

Generator(binary_string, index + 1)

binary_string[index] = 'X'

else:

# If The Character At A Particular Index is Not 'X' Then

# Calling For Function For Next Index

Generator(binary_string, index + 1)

# Driver code

string = input()

binary_strings(string)

You might be interested in
Write a Python 3 program that will compute the total cost of an amazon purchase. The program should ask the user to enter the am
valentina_108 [34]

Answer:

price = float(input("Enter amount of a purchase: "))

shipping_price = 0.12* price

NJ_sales_Tax = 0.07*price

print('The price of item is {}'.format(price))

print('The Cost of Shipping is {}'.format(shipping_price) )

print('New Jessey Sales Tax is {}'.format(NJ_sales_Tax))

total_bill = shipping_price+NJ_sales_Tax+price

print('Total Bill {} ' .format(total_bill))

Explanation:

  • Prompt User for input of the amount of purchase
  • Calculate the shipping cost (12% of purchase price)
  • Calculate the tax (7% of the purchase price)
  • Use python's .format method to output an itemized bill

3 0
3 years ago
Which of the following translates packets so that the node can understand them once they enter through a port?
FinnZ [79.3K]
A cluster compute server includes nodes coupled in a network ... Each VNIC typically is assigned its own MAC address by the VMM or VM, ... translation or mapping storage at the NIC of each node in the cluster ...... a wired or wireless network (e.g., network accessible storage (NAS)). .... Google Translate ...
5 0
4 years ago
Read 2 more answers
30.1 LAB*: Warm up: Online shopping cart (Part 1) (1) Create three files to submit: ItemToPurchase.h - Class declaration ItemToP
nlexa [21]

Answer:

see explaination

Explanation:

#ifndef ITEMTOPURCHASE_H

#define ITEMTOPURCHASE_H

#include<iostream>

using namespace std;

class ItemToPurchase

{

public:

ItemToPurchase();

void setItemName(string name);

void setItemPrice(int itemPrice);

void setItemQuantity(int itemQuantity);

string getItemName();

int getItemPrice();

int getItemQuantity();

virtual ~ItemToPurchase();

protected:

private:

string itemName ;

int itemPrice;

int itemQuantity ;

};

#endif // ITEMTOPURCHASE_H

#include "ItemToPurchase.h"

ItemToPurchase::ItemToPurchase()

{

//ctor

this->itemName="none";

this->itemPrice=0;

this->itemQuantity=0;

}

void ItemToPurchase::setItemName(string name)

{

this->itemName=name;

}

void ItemToPurchase::setItemPrice(int itemPrice)

{

this->itemPrice=itemPrice;

}

void ItemToPurchase::setItemQuantity(int itemQuantity)

{

this->itemQuantity=itemQuantity;

}

string ItemToPurchase::getItemName()

{

return itemName;

}

int ItemToPurchase::getItemPrice()

{

return itemPrice;

}

int ItemToPurchase::getItemQuantity()

{

return itemQuantity;

}

ItemToPurchase::~ItemToPurchase()

{

//dtor

}

#include <iostream>

#include "ItemToPurchase.h"

using namespace std;

int main()

{

ItemToPurchase item1,item2;

string itemName ;

int itemPrice;

int itemQuantity ;

int totalCost=0;

cout<<"Item 1:"<<endl;

cout<<"Enter the item name : ";

getline(cin,itemName);

//cin.ignore();

cout<<"Enter the item price : ";

cin>>itemPrice;

cout<<"Enter the item quantity : ";

cin>>itemQuantity;

item1.setItemName(itemName);

item1.setItemPrice(itemPrice);

item1.setItemQuantity(itemQuantity);

cin.ignore();

cout<<"Item 2:"<<endl;

cout<<"Enter the item name : ";

getline(cin,itemName);

//cin.ignore();

cout<<"Enter the item price : ";

cin>>itemPrice;

cout<<"Enter the item quantity : ";

cin>>itemQuantity;

item2.setItemName(itemName);

item2.setItemPrice(itemPrice);

item2.setItemQuantity(itemQuantity);

cout<<"TOTAL COST : "<<endl;

cout<<item1.getItemName()<<" "<<item1.getItemQuantity()<<" at $"<<item1.getItemPrice()<<" = "<<(item1.getItemQuantity()*item1.getItemPrice())<<endl;

cout<<item2.getItemName()<<" "<<item2.getItemQuantity()<<" at $"<<item2.getItemPrice()<<" = "<<(item2.getItemQuantity()*item2.getItemPrice())<<endl;

totalCost=(item1.getItemQuantity()*item1.getItemPrice())+(item2.getItemQuantity()*item2.getItemPrice());

cout<<"Total : $"<<totalCost<<endl;

return 0;

}

Note: Replace at with the at symbol

See attachment for output

3 0
3 years ago
Local area networks use many of the same network technologies and the Internet, only on a smaller scale. Devices that access LAN
enot [183]

Answer:

Fill in the gaps accordingly in the order below.

Explanation:

-Controller

-Media Access Control

-Ethernet

- WiFi

-Mesh

-Password

-SSID

-Encryption

-Guest

-DHCP

-Key

-Low

5 0
3 years ago
What is the function of a bread crumb trial in a website
joja [24]

Answer:

A “breadcrumb” (or “breadcrumb trail”) is a type of secondary navigation scheme that reveals the user's location in a website or Web application. The term comes from the Hansel and Gretel fairy tale in which the two title children drop breadcrumbs to form a trail back to their home.

Explanation:

A breadcrumb or breadcrumb trail is a graphical control element frequently used as a navigational aid in user interfaces and on web pages. It allows users to keep track and maintain awareness of their locations within programs, documents, or websites. Breadcrumbs make it easier for users to navigate a website – and they encourage users to browse other sections of the site. ... You head to their site and end up on The Nestle company history page. Using their breadcrumbs, you can easily navigate back to About Us, History, or even their home page.

6 0
3 years ago
Other questions:
  • Manipulate the SQL statement to pull ALL fields and rows from Customers table that have a PostalCode of 44000. TIP: Since Postal
    13·1 answer
  • according to the National Automobile Dealers Association, a single dealership may employ people with as many as 57 different A.
    6·1 answer
  • Phoebe has to give a permission about recycling. Where should she look while presenting?
    11·1 answer
  • At the monthly product meeting, one of the Product Owners proposes an idea to address an immediate shortcoming of the product sy
    7·1 answer
  • When was kale discovered?
    9·1 answer
  • How do you join The Meeting on zoom because I have class Tomorrow with My Teacher
    7·2 answers
  • Which of the following is not a key component of a structure?
    6·1 answer
  • Given the following class: Create a class MyGenerator that can be used in the below main method.
    8·1 answer
  • What is the processing speed for the second generation of computers​
    7·1 answer
  • Did you know you can buy a Passport Online?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!