Home python 3.6 basics: Create a program that captures user input and uses variables to store the addresses to be printed
Reply: 0

python 3.6 basics: Create a program that captures user input and uses variables to store the addresses to be printed

user11443
1#
user11443 Published in September 21, 2018, 8:29 am

Please help :)

Write a program to collect input from the user for two complete addresses (name, street number, street name, city, state, and zip code) from the command-line prompt. You will first need to create variables to store the addresses in the variables, and then create the appropriate built-in functions to capture the input from the addresses from the user. The street number and zip must be represented in the system as numerical values. Create a program that captures user input and uses variables to store the addresses to be printed.

I know I need to use eval(input()) to convert the characters to numerical values.

I have this as an outline in python for mac currently, just need to enter the information but I am stuck on what "\n" means. as well as where to enter the information.

#user input for first address
print ("\nEnter first address")
name1 = input("Name: ")
streetName1 = input("Street Name: ")
streetNumber1 = input("Street Number: ")
city1 = input("City: ")
#user input for first address
print ("\nEnter first address")
name1 = input("Name: ")
streetName1 = input("Street Name: ")
streetNumber1 = input("Street Number: ")
city1 = input("City: ")
state1 = input("State: ")
zip1 = input("Zip Code: ")
#user input for first address
print ("\nEnter second address")
name2 = input("Name: ")
streetName2 = input("Street Name: ")
streetNumber2 = input("Street Number: ")
city2 = input("City: ")
state2 = input("State: ")
zip2 = input("Zip Code: ")

print both address

print ("\nFirst address is :")
print ("Name", name1)
print ("Street Name", streetName1)
print ("Street Number", streetNumber1)
print ("City", city1)
print ("State", state1)
print ("Zip Code", zip1)

print ("\nSecond address is :")
print ("Name", name2)
print ("Street Name", streetName2)
print ("Street Number", streetNumber2)
print ("City", city2)
print ("State", state2)
print ("Zip Code", zip2)
share|improve this question
  • Which part are you stuck on? Please provide a Minimal, Complete, and Verifiable example. – jpaugh Feb 12 at 23:16
  • Please, read How do I ask and answer homework questions? – JP Ventura Feb 12 at 23:17
  • 1
    I'll note that you don't want to use eval(), but int() to convert string to an integer, not just for security reasons, but also because Zip Codes starting with zero will not be converted! – Ken Y-N Feb 12 at 23:25
  • 1
    I just updated my question to have the outline of the code and explained where I am stuck at within the code. I am sorry for not posting properly this is my first time here and I am learning the ways – program123 Feb 12 at 23:26
  • this was provided by professor as an example: myname = input("Name: ") myage = eval(input("Age: ")) mysalary = eval(input("Salary: ")) print ("My name is", myname) print ("I am", myage) print ("I earn", mysalary) – program123 Feb 12 at 23:27

1 Answer 1

active oldest votes
up vote 0 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.579431 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO