Last active
March 9, 2016 01:39
-
-
Save Kwisses/1147f9e3b12f386acfd8 to your computer and use it in GitHub Desktop.
[Daily Challenge #1 - Easy] - Information Return - r/DailyProgrammer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ***** DAILY CHALLENGE #1 - Easy ***** | |
# Create a program that will ask the users name, age, and Reddit username. have it tell them the information back, | |
# In the format: | |
# | |
# your name is (blank), you are (blank) years old, and your username is (blank) | |
# | |
# for extra credit, have the program log this information in a file to be accessed later. | |
# --------------------------------------------------------------------------------------------------------------------- | |
def information(name, age, username): | |
"""Echos information back to the user. | |
Args: | |
name (str): Name of user. | |
age (str): Age of user. | |
username (str): Username of user. | |
Return: | |
str: Contains information about the user. | |
""" | |
result = "Your name is %s, you are %s years old, and your username is %s" % (name, age, username) | |
my_file.write(str(result) + "\n") | |
return result | |
my_file = open("Challenge_1_easy_save", "r+") | |
n = input("Name: ") | |
a = input("Age: ") | |
user = input("Username: ") | |
output = information(n, a, user) | |
my_file.close() | |
print(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Your name is John, you are 22 years old, and your username is Kwistech |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[Daily Challenge #1 - Easy] from the DailyProgrammer subreddit. As a bonus, the code writes the users input to a .txt file.
Reference: https://www.reddit.com/r/dailyprogrammer/comments/pih8x/easy_challenge_1/