Skip to content

Instantly share code, notes, and snippets.

@akaomy
Created October 7, 2016 22:54
Show Gist options
  • Save akaomy/ef6bff4656c2589dae8a5178ef3ab089 to your computer and use it in GitHub Desktop.
Save akaomy/ef6bff4656c2589dae8a5178ef3ab089 to your computer and use it in GitHub Desktop.
Python practice
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.5.2 (/usr/bin/python3.5)" project-jdk-type="Python SDK" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/python-practice.iml" filepath="$PROJECT_DIR$/.idea/python-practice.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
"""
program that asks the user to enter their name and their age.
Print out a message addressed to them that tells them the year that they will turn 100 years old.
Taken from here: http://www.practicepython.org/exercise/2014/01/29/01-character-input.html
"""
from datetime import date
user_name = input("Please enter your name here: ")
user_age = int(input("Enter your age: "))
# Calculate what year it will be in 100 years
current_year = date.today().year
year_in_hundred_years = current_year + 100
# Calculate in how much years user will be 100 years old
age_in_hundred_years = 100 - user_age
# Strings concatenations
result = "Hi " + user_name + "!"
result2 = "You will be 100 years old in " + str(
age_in_hundred_years) + " years" # cannot use int to concatenate to string
result3 = "And the year will be: " + str(year_in_hundred_years)
# Output
print(result)
print(result2)
print(result3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment