i scripted a code for conversion of temperature fromm celsius to fahrenheit.

convert celsius to fahrenheit

celsius=int(input("Please enter the value for temperature:"))


print (fahrenheit)
input ("Please press return to exit.")

Wanted to know how can i add a line in the print setion ie. while displaying the output,it should show as "The value for temperature in fahrenheit is:".Please enlighten.


ideally, use .format():

print("The value for temperature in fahrenheit is: {:d}".format(fahrenheit))

see here, for more information about format


its showing as syntax error


Got it!!its running.Thank you.


I am not saying .format() is the only way, but its the recommendent way

not sure how you got a syntax error, good that you solved it


Can this format be used in the scripts where the output is an integer?


what are the other ways?


yes, of course, did you see the website i linked to:

it explains .format() in more detail, well then we have the old style (%d) which is explained there as well, then we have:

print("The value for temperature in fahrenheit is:", farenheit)

and string concenate:

print("The value for temperature in fahrenheit is: " + str(farenheit))


Okay ,i will check it.


Thank you :slight_smile:


For taking in input containing only strings for it is: value=str(input("please enter a value"))
for numbers its: value=int(input("please enter a value")).
But may i know what is the syntax for taking in a mixture of alphabets and numbers?


in programming, there isn't way one way to do something. So there isn't one way to solve what you are asking, there are several.

you could make separate prompts

integers can be represent as string. So depending on what you need it for, string integers might suit you

you could check for each character the user inputted if its a number (you can google this)


Is this script technically correct?

#Login script
#Enter username and password
username=str(input("PLEASE ENTER USERNAME"))
password=int(input("PLEASE ENTER PASSWORD"))
if (username==sudeep) and (password==18051993):
    print ("Logged in")
    print("Invalid login credentials")


no, here:


sudeep is a undefined variable, and it overwrites the user input, why would you do this?


if (username==sudeep)

sudeep is a string, a string requires quotation marks or apostrophes


Yes!!got it ..Thank you


Facing an issue here.The program runs,but even when i input the correct username and password it shows "invalid login credentials".


i ran your code here, everything works fine, i was able to login succesfully


what is ur problem that i can help u with


Actually facing an issue with the login script.


I tried runnng it.So the scrpt is okay?