def main(): # Инициализиировать переменную для управления циклом. again = 'д' # Открыть файл. with open(FILENAME, 'wb') as output_file: # Получить данные от пользователя. while again.lower() == 'д': # Получить данные о сотовом телефоне. man = input('Введите производителя: ') mod = input('Введите номер модели: ') retail = float(input('Введите розничную цену: ')) # Создать объект CellPhone. phone = cellphone.CellPhone(man, mod, retail) # Законсервировать объект и записать его в файл. pickle.dump(phone, output_file) # Получить еще один элемент данных? again = input('Введёте еще один элемент данных? (д/н): ') # Закрыть файл. output_file.close() print('Данные записаны в', FILENAME)
def main(): # initialize a variable to control the loop. again = "y" # open a file. output_file = open(FILENAME, "wb") # get the data from the user. while again.lower() == "y": # get the cell phone data. man = input("Enter the manufacturer: ") mod = input("Enter the model number: ") retail = float(input("Enter the retail price: ")) # create a CellPhone object. phone = cellphone.CellPhone(man, mod, retail) # pickle the object and write it to the file. pickle.dump(phone, output_file) # get more cell phone data? again = input("enter more phone data? (y/n): ") # close the file. output_file.close() print("The data was written to", FILENAME)
def main(): # Inicjalizacja zmiennej kontrolującej działanie pętli. again = 't' # Otworzenie pliku. output_file = open(FILENAME, 'wb') # Pobranie danych od użytkownika. while again.lower() == 't': # Pobranie danych o telefonie komórkowym. man = input('Podaj producenta telefonu: ') mod = input('Podaj numer modelu telefonu: ') retail = float(input('Podaj cenę detaliczną telefonu: ')) # Utworzenie obiektu klasy CellPhone. phone = cellphone.CellPhone(man, mod, retail) # Serializacja obiektu i jego zapis w pliku. pickle.dump(phone, output_file) # Czy będą podane dane o kolejnym telefonie komórkowym? again = input('Czy chcesz podać dane kolejnego telefonu komórkowego? (t/n): ') # Zamknięcie pliku. output_file.close() print('Dane zostały zapisane w pliku ', FILENAME)
def main(): # Initialize a variable to control the loop. again = 'y' # Open a file. output_file = open(FILENAME, 'wb') # Get data from the user. while again.lower() == 'y': # Get cell phone data. man = input('Enter the manufacturer: ') mod = input('Enter the model number: ') retail = float(input('Enter the retail price: ')) # Create a CellPhone object. phone = cellphone.CellPhone(man, mod, retail) # Pickle the object and write it to the file. pickle.dump(phone, output_file) # Get more cell phone data? again = input('Enter more phone data? (y/n): ') # Close the file. output_file.close() print('The data was written to', FILENAME)
def main(): again = 'y' output_file = open(FILENAME, 'wb') while again.lower() == 'y': # man = input('Enter the Manufacture: ') mod = input('Enter the Model #: ') retail = float(input('Enter the retail price: ')) # phone = cellphone.CellPhone(man, mod, retail) # pickle.dump(phone, output_file) # again = input('Enter more phone data? (y/n): ') # output_file.close() print('The data was written to', FILENAME)
def main(): cell_man = input("Enter cell phone manufacture :") cell_name = input("Enterr cell phone name :") cell_price = float(input("Enter cell phone price")) #Creating the instance of Cell phone phone = cellphone.CellPhone(cell_man, cell_name, cell_price) print(phone.getManu()) print(phone.getModel()) print(phone.getPrice())
def main(): manufacturer = input('Enter the manufacturer: ') model = input('Enter the model number: ') retail = float(input('Enter the retail price: ')) phone = cellphone.CellPhone(manufacturer, model, retail) print('Here is the data that you entered:') print('Manufacturer:', phone.get_manufact()) print('Model:', phone.get_model()) print('Retail price:', phone.get_retail_price())
def main(): man=input('Enter the manufacturer: ') mod=input('Enter the model number: ') retail=float(input('Enter the retail price: ')) # Creat an instance of the Cellphone class. phone=cellphone.CellPhone(man,mod,retail) print('Here is the data that you entered:') print('Manufacturer:',phone.get_manufact()) print('Model Number:',phone.get_model()) print('Retail Price:$',format(phone.get_retail_price(),',.2f'),sep='')
def main(): # Pobranie danych o telefonie komórkowym. man = input('Podaj producenta telefonu: ') mod = input('Podaj numer modelu telefonu: ') retail = float(input('Podaj cenę detaliczną telefonu: ')) # Utworzenie egzemplarza klasy CellPhone. phone = cellphone.CellPhone(man, mod, retail) # Wyświetlenie podanych danych. print('Oto podane przez Ciebie dane:') print('Producent:', phone.get_manufact()) print('Numer modelu:', phone.get_model()) print('Cena detaliczna:', format(phone.get_retail_price(), '.2f'), sep='')
def main(): # Get the phone data man = input('Enter the manufacturer:\n') mod = input('Enter the model number:\n') retail = float(input('Enter the retail price:\n')) # Create an instance of the CellPhone class phone = c.CellPhone(man, mod, retail) # Display the data that was entered print('Here is the data that you entered:') print('Manufacturer: ', phone.get_manufact()) print('Model Number: ', phone.get_model()) print(f'Retail Price: ${phone.get_retail_price():,.2f}')
def main(): # Получить данные о телефоне. man = input('Введите производителя: ') mod = input('Введите номер модели: ') retail = float(input('Введите розничную цену: ')) # Создать экземпляр класса CellPhone. phone = cellphone.CellPhone(man, mod, retail) # Показать введенные данные. print('Вот введеные Вами данные: ') print('Производитель:', phone.get_manifact()) print('Номер модели:', phone.get_model()) print('Розничная цена: ₽', format(phone.get_retail_price(), '.2f'), sep='')
def main(): # get the phone data. man = input('Enter the manufacturer: ') mod = input('Enter the model: ') retail = float(input('Enter the retail price: ')) # Creates an instance of the cellphone class phone = c.CellPhone(man, mod, retail) # display the data that was entered print('Here is the data you entered') print('Manufacturer: ', phone.get_manufact()) print('Model: ', phone.get_model()) print(f'Retail Price: ${phone.get_price():,.2f}')
def main(): # get the phone data. man=input("Enter the manufacturer: ") mod=input("Enter the model number: ") retail=float(input("Enter the retail price: ")) # create an instance of the CellPhone class. phone=cellphone.CellPhone(man,mod,retail) # display the data that was entered. print() print("Here is the data you entered: ") print("Manufacturer:", phone.get_manufact()) print("Model Number:", phone.get_model()) print("Retail Price: $", format(phone.get_retail_price(), ",.2f"), sep="")
def make_list(): phone_list = [] #Add five Cellpone objects to the list. for count in range(1,6): print ('phone number ' + str(count) + ':') man = input('Enter Manufacturer: ') mod = input('Enter the model number: ') retail = float(input('Enter the retail price: ')) print() #Create a new CellPhone object in memory and #assign it to the variable. phone = cellphone.CellPhone(man,mod, retail) #Add the object to the list. phone_list.append(phone) return phone_list
def make_list(): #Create empty list phone_list = [] #Add five CellPhone objects to the list print('Enter data for five phones.') for count in range(1,6): #Get the phone data print('Phone number ' +str(count) +':') man = input('Enter the manufacturer:\n') mod = input('Enter the model number:\n') retail = float(input('Enter the retail price:\n')) print() phone = c.CellPhone(man,mod,retail) phone_list.append(phone) return phone_list
def make_list(): # Create an empty list phone_list = [] # Add 5 phone objects to the list print('Enter data for five phones.') for count in range(1, 6): print('Phone number ' + str(count) + ':') man = input('Enter the manufacturer: ') mod = input('Enter the model number: ') retail = float(input('Enter the retail price: ')) print() # Create phone object in memory phone = cp.CellPhone(man, mod, retail) # Add phone object to the list phone_list.append(phone) return phone_list
def main(): # Create the main function again = 'y' # Initialize a variable to control the loop output_file = open( FILENAME, 'wb') # Write back to the file that is open & which was created above while again.lower() == 'y': # While the again = 'y' man = input("Please enter the manufacturer: ") mod = input("Please enter the model: ") retail = float(input("Please enter the retail price: ")) phone = cellphone.CellPhone(man, mod, retail) # Create the cell phone object pickle.dump( phone, output_file) # Pickle the object and send it to the output_file again = input("Would you like to enter more phone data? (y/n): ") output_file.close() # Close the file in question print("The data was written to", FILENAME)
def make_list(): # Define the make list function phone_list = [] # Create an empty list # Add five cell phones to the list for x in range(1, 6): print("Phone number" + " " + str(x) + ' :') # Print out the number that the user is currently on man = input( "Please enter the manufacturer: ") # Input the manufacturer mod = input("Please enter the model of the phone: " ) # Input the model of the phone retail = float(input("Please enter the price of the phone: ") ) # Input the price of the phone print("") # Print a blank line # Create a new CellPhone object and assign it in memory phone = cellphone.CellPhone(man, mod, retail) # Create the new object phone_list.append(phone) # Append the phone_list with the new value return phone_list # Return the cell phone list from the function
def main(): # Init a varialble to control the loop again = 'y' # Open the output file output_file = open(FILENAME, 'wb') # Get the phone data while again.lower() == 'y': man = input("Enter the manufacturer: ") mod = input("Enter the model: ") price = float(input("Enter the price: ")) phone = cellphone.CellPhone(man, mod, price) pickle.dump(phone, output_file) again = input("Enter more phone data? (y/n) ") output_file.close() print(f"Data was written to {FILENAME}")
def make_list(): # Создать пустой список. phone_list = list() # Добавить пять объектов CellPhone в список. print('Введите данные о пяти телефонах.') for count in range(1, 6): # Получить данные о телефоне. print('Номер телефона ' + str(count) + ":") man = input('Введите производителя: ') mod = input('Введите номер модели: ') retail = float(input('Введите розничную цену: ')) print() # Создать новый объект CellPhone в памяти # и присвоить его переменной phone. phone = cellphone.CellPhone(man, mod, retail) # Добавить объект в список. phone_list.append(phone) # Вернуть список. return phone_list
def make_list(): # Utworzenie pustej listy. phone_list = [] # Dodanie pięciu obiektów CellPhone do listy. print('Podaj dane pięciu telefonów komórkowych.') for count in range(1, 6): # Pobranie danych o telefonie komórkowym. print('Telefon nr ' + str(count) + ':') man = input('Podaj producenta telefonu: ') mod = input('Podaj numer modelu telefonu: ') retail = float(input('Podaj cenę detaliczną telefonu: ')) print() # Utworzenie w pamięci nowego obiektu CellPhone # i przypisanie go zmiennej phone. phone = cellphone.CellPhone(man, mod, retail) # Dodanie obiektu do listy. phone_list.append(phone) # Zwrot listy. return phone_list
def make_list(): # create an empty list. phone_list = [] # add five CellPhone objects to the list. print("Enter data for five phones.") print() for count in range(1, 6): # get the phone data. print("Phone number ", str(count), ":", sep="") man = input("Enter the manufacturer: ") mod = input("Enter the model number: ") retail = float(input("Enter the retail price: ")) print() # create a new CellPhone object in memory and # assign it to the phone variable. phone = cellphone.CellPhone(man, mod, retail) # add the object to the list. phone_list.append(phone) # return the list return phone_list
def make_list(): # create an empty list phone_list = [] # Add five cellphone objects to the list print('Enter data for five phones. ') for count in range(1, 6): #get the phone data print('Phone Number ' + str(count) + ':') man = input('Manufacturer: ') mod = input('Model: ') price = float(input('Price: ')) print() # Create a new CellPhone object in memory then # assign it to the new phone variable phone = cellphone.CellPhone(man, mod, price) # Add the object to the list phone_list.append(phone) #Return the list return phone_list
def make_list(): # Create an empty list. phone_list = [] # Add five CellPhone objects to the list. print('Enter data for five phones.') for count in range(1, 6): # Get the phone data. print('Phone number ' + str(count) + ':') man = input('Enter the manufacturer: ') mod = input('Enter the model number: ') retail = float(input('Enter the retail price: ')) print # Create a new CellPhone object in memory and # assign it to the phone variable. phone = cellphone.CellPhone(man, mod, retail) # Add the object to the list. phone_list.append(phone) # Return the list. return phone_list
def main(): again = 'y' # Open a file output_file = open(FILENAME, 'wb') # Get data from the user while again.lower() == 'y': # Get cellphone data man = input('Enter the manufacturer: ') mod = input('Enter the model number: ') retail = float(input('Enter the retail price: ')) phone = cellphone.CellPhone(man, mod, retail) # Pickle the object and write it to the file pickle.dump(phone, output_file) again = input('Enter more phone data? (y/n): ') # Close the file output_file.close() print('Data was written to', FILENAME)
def main(): man = input('What is your phone\'s manufacture? ') mod = input('What is your phone\'s model? ') price = float(input('What is your phone\'s price? ')) cellphone = cellphone.CellPhone(man, mod, price)
def main(): c = cellphone.CellPhone("Samsung", "Note 8", 600.13) print(f"Manufacturer: {c.get_manufact()}") print(f"Model: {c.get_model()}") print(f"Price: {c.get_price():.2f}")