Python User Input

Python User Input –Python Хэрэглэгчийн Оролт #

User Input – Хэрэглэгчийн Оролт  #

Python allows for user input.

Python хэл нь хэрэглэгч оролт авах боломжийг олгодог.

That means we are able to ask the user for input.

Энэ нь бид хэрэглэгчээс мэдээлэл авах боломжтой гэсэн үг юм.

The method is a bit different in Python 3.6 than Python 2.7.

Энэ арга нь Python 3.6 болон Python 2.7 хувилбаруудад өөр өөр байдаг.

Python 3.6 uses the input() method.

Python 3.6 хувилбарт input() аргыг ашигладаг.

Python 2.7 uses the raw_input() method.

Python 2.7 хувилбарт raw_input() аргыг ашигладаг.

The following example asks for the username, and when you entered the username, it gets printed on the screen:

Доорх жишээ нь хэрэглэгчийн нэрийг асууж, хэрэглэгчийн нэрийг оруулсны дараа дэлгэцэн дээр хэвлэгдэнэ:

Python 3.6 #

username = input("Enter username:")
print("Username is: " + username)

Python 2.7 #

username = raw_input("Enter username:")
print("Username is: " + username)

Python stops executing when it comes to the input() function, and continues when the user has given some input.

input() функцэд ирэхэд Python програм ажиллахаа больж, хэрэглэгчийн өгсөн оролтын дараа үргэлжлүүлэн ажилладаг.

Powered by BetterDocs

Leave a Reply