Python - input function exercise

Assignment Help Python Programming
Reference no: EM133059340 , Length: word count:300

Learning Activity: Programming Exercise

With this learning activity, you will learn how to read user's input and how to read Python official documentation.

First navigate to this small section on Python's official documentation: There is no programming class that can cover all features and its library of a programming language. You will need to learn to read the language's official documentation to how to get things done.

In this example, you will learn how to read in users' input from the keyboard. The built-in function to achieve that is the input() function. For now think about functions as some little helpers that take in some inputs, do something for you, and may also produce some outputs.

In the official documentation, it shows the syntax for the input() function is: input([prompt])

You can include some prompt message to guide users' input. For example, input(‘Please enter your age: '). The screen will output the prompt message then wait for user's input. This function returns the users' input as a string. Please refer to the example in the official documentation.

Now that you have learnt the input function, let's do exercise to put it in practice. Write a program in Python that asks the user to input the year they were born and outputs their age (approximately) using the current year minus the year they were born. HINT: you will need to convert users' input to an integer.

Sample input/output:
>>> Please enter the year you were born:
>>> 1991
>>> You will turn 30 in year 2021.

Post your implementation to the Module 1.2 Programming Exercise 1 discussion forum. Since this question asks you to write a program, lease upload your code as a Python code file (.py file) and do not copy and paste your code in the discussion forum text editor as the indentation may be lost. Indentations in Python indicate code blocks and scope and is part of the code.

Attachment:- Programming Exercise.rar

Reference no: EM133059340

Questions Cloud

Python - integer division and modulus operator : Write a program in Python that asks the user to input a three-digit number, and outputs the three-digit separated by a comma
How do management and leadership complement : How do management and leadership complement each other within the organization?
What is the assigned value of the ordinary stock warrants : The market value of Pink's ordinary was P 20 per share, and the market value of the bonds ex-warrant was P97. What is the assigned value of the ordinary stock
Strategies affect firm strategic competitiveness : How would the board's increased involvement in the selection of strategies affect a firm's strategic competitiveness?
Python - input function exercise : How to read users input and how to read Python official documentation - First navigate to this small section on Python's official documentation
Tough time with bidding process : Imagine that you are a small-business owner. You are having a tough time with the bidding process;
What were the equivalent units of direct materials : Direct materials costs added during February 1,000,000. What were the equivalent units of direct materials and conversion costs, respectively
Business process and earned value management : Identify the business processes that must be created or will be affected. Address the personnel establishment that practices earned value management
Discuss the two key perspectives you have researched : Discuss the two key perspectives you have researched about why business would generally prefer to select its own methods of accounting for social performance

Reviews

Write a Review

Python Programming Questions & Answers

  Build a refrigerator code using python programming principle

Build a Refrigerator code using python programming principles - implement two methods, put and get. Put will allow you to put some object in to refrigerator

  Make automobile class that will be used by a dealership

Make automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present in your automobile class.

  Calculate the average test score for a certain number

Write a program that will allow a teacher to calculate the average test score for a certain number of students. Calculate the average score.

  Write a script or a program that reads a text file

Write a script or a program that reads a text file of pre-processed documents, creates a Term Document Incident Matrix and an inverted index

  What will be displayed after the code runs

Assuming the random module has been imported into its default namespace, which of the following could be used to generate a random even integer.

  Explain the value of testing in programming

Discuss the role that the compiler plays in translating between a high-level programming language and the low-level machine language native to the computer.

  Define a word as ending a sentence

Define a word as ending a sentence if that word is immediately followed by a period. A startwords function that takes a single string argument.

  Design a program that asks the user to enter monthly sales

Design a program that asks the user to enter the monthly sales values for six months. The program should store the monthly sales values in a list.

  Graphing calculator assignment

Graphing Calculator Assignment - Discussing the assignment requirements with others is a reasonable thing to do, and an excellent way to learn.

  Design and implement two related programs

CSP1150/CSP5110 Programming Principles Assignment - programming project (WordChain). You are required to design and implement two related programs

  Add an option for the computer to guess as well as the user

You will add quite a bit of code to your project. You will add an option for the computer to guess as well as the user to guess a number.

  Create a python list and add employee objects and manager

Create a Python list and add Employee objects and Manager objects to the same list. Use a loop to give a raise() to every object in the list.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd