Write a python program to print the value of 2 2n n 5 for n provided by the user
Python Basic: Exercise-10 with SolutionWrite a Python program that accepts an integer (n) and computes the value of n+nn+nnn. Sample value of n is 5 Python int(x, base=10): The function returns an integer object constructed from a number or string x, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
Pictorial Presentation: Sample Solution :- Python Code:
Sample Output: 615 Flowchart: Visualize Python code execution:The following tool visualize what the computer is doing step-by-step as it executes the said program: Python Code Editor: Have another way to solve this solution? Contribute your code (and comments) through Disqus. Previous: Write a Python program to display the examination schedule. (extract the date from exam_st_date). This is a Python Program to read a number n and compute n+nn+nnn. Problem Description The program takes a number n and computes n+nn+nnn. Problem Solution 1. Take the value of a element and store in a variable n. Program/Source Code Here is the source code of the Python Program to read a number n and compute n+nn+nnn. The program output is also shown below. n=int(input("Enter a number n: ")) temp=str(n) t1=temp+temp t2=temp+temp+temp comp=n+int(t1)+int(t2) print("The value is:",comp) Program Explanation 1. User must first enter the value and store it in a variable n. Runtime Test Cases Case 1: Enter a number n: 5 The value is: 615 Case 2: Enter a number n: 20 The value is: 204060 Sanfoundry Global Education & Learning Series – Python Programs. To practice all Python programs, here is complete set of 150+ Python Problems and Solutions. Next Steps:
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn. Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses. |