UrbanPro

Learn Python Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

X=4 Y=X+4 Y=INT(STR(Y)+'2') PRINT(Y)

Asked by Last Modified  

25 Answers

Learn Python

Follow 0
Answer

Please enter your answer

Expert Programmer

82
Comments

Here is how it works: 1. X takes the value of 4 2. Y takes the value of 8 ( Y=X+4 ) 3a. str(Y) is evaluated as '8' 3b. next, str(Y)+'2' is evaluated - this gives us '82' 3c. next, INT('82') gets evaluated - which returns 82 and assigns it to Y. 4. No wonder 82 is printed.
Comments

82
Comments

22 Years Experienced Python Coding Computer Science ICT AI Java Maths Gurugram Tuitions Classes 6-12

This will print 82 and the for the reason, please have a look at the answer by Rajaram as it is well explained
Comments

82
Comments

Software Programmer

82
Comments

Advance C-Embedded

82
Comments

Tutor

INT, STR and PRINT have to be in lower case, else nothing is going to work. Python needs all functions to be defined in lower case. Then the answer would be 82 as everybody else has pointed out.
Comments

10
Comments

Tutor

Hello Annu, Please find below for the detailed explanation X=4 print 'X:', X, type(X) Y=X+4 print 'Y:', Y, type(Y) print 'str(Y)---', str(Y), type(str(Y)) print "str(Y)+'2'---", str(Y)+'2', type(str(Y)+'2') print "int(str(Y)+'2') ======", int(str(Y)+'2'), type(int(str(Y)+'2')) Y=int(str(Y)+'2') print...
read more
Hello Annu, Please find below for the detailed explanation X=4 print 'X:', X, type(X) Y=X+4 print 'Y:', Y, type(Y) print 'str(Y)---', str(Y), type(str(Y)) print "str(Y)+'2'---", str(Y)+'2', type(str(Y)+'2') print "int(str(Y)+'2') ======", int(str(Y)+'2'), type(int(str(Y)+'2')) Y=int(str(Y)+'2') print type(Y) ======================================== python .\sample-exp.py X: 4 type 'int' Y: 8 type 'int' str(Y)--- 8 type 'str' str(Y)+'2'--- 82 type 'str' int(str(Y)+'2') ====== 82 type 'int' type 'int' PS F:\Python ====================================================== Point-1: Initially both the variables X,Y are integers Point-2: At step-3 you converted variable 'Y' to string and concatenated('+') with '2' which resulted '82', a string This string '82' was again converted to int by the python int function The result is a integer value 82 for the variable 'Y' point-3: At step-4 you printed Y value which will be an integer output. You can use type() function to check, which class the variable belongs to. read less
Comments

View 23 more Answers

Related Questions

Which is best to build web applications: PHP, Python, or Ruby? Why?
I have used almost all of the three language in my web working experience.PHP:It may be not that cool and I think it doesn't rely too much on the framework. Yes, PHP is just a language, but it is the only...
Sunil
0 0
7
Hi, I'm BCA graduate, and I have seven years in the general insurance field now I want to change my profile and upgrade my knowledge. Will learning python help me with my growth in my career?
Hi, as far as my knowledge goes first, you should learn data processing tools or programs like MS Excel, Power Bi, or SQL then you should then take a leap into Python, which will make automating your work quite simple.
Supriya

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Different types of data in python3
Python3 features Numbers(int,float,complex), String, Lists, Tuples, Dictionary and Sets type of data. long interger type numbers from python2 is no longer required. Below are examples of all python3 data...

What Is the Identifier and Data Types in Python?
It is used for identification purpose like- x=10; where x is variable, and it can be store int type value in the x variable. Rules of identifier:- It can be started with underscore like:- _x=10 It...

Writing Simple programs in Python(cont.)
To start writing simple programs in Python, we have to know firstly the SW development process and then we also have to know a bit about the language in which we wish to code,in this case,python, to get...

OS Module
1. OS module interacts with your operating system. Use this to create folder, remove folder, move folder, change the working directory. Ex: import oscurDir=os.getcwd() #get current working directoryprint(curDir)os.mkdir('praveen')...

JAVA - Object Cloning
JAVA - Object Cloning Is the way of creating the same copy of object without calling the class constructor. It means we can make any class object multiple times without calling its default constructor....

Recommended Articles

Python is one of the most popular programming languages in the world. It is general-purpose, object oriented, high-level programming language used in a number of programming fields. Python is a great programming language to learn as it will introduce you to the world of programming. If you are from the technical background...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Applications engineering is a hot trend in the current IT market.  An applications engineer is responsible for designing and application of technology products relating to various aspects of computing. To accomplish this, he/she has to work collaboratively with the company’s manufacturing, marketing, sales, and customer...

Read full article >

Looking for Python Training classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Python Training Classes?

The best tutors for Python Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Python Training with the Best Tutors

The best Tutors for Python Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more