Python operator.lt()函數與示例

operator.lt()函數 (operator.lt() Function)

operator.lt() function is a library function of operator module, it is used to perform "less than operation" on two values and returns True if the first value is less than the second value, False, otherwise.

operator.lt()函數是運營商模塊的庫函數,它被用于在兩個值并返回true執行“小于操作”如果第一值小于所述第二值, 假 ,否則。

Module:

模塊:

    import operator

Syntax:

句法:

    operator.lt(x,y)

Parameter(s):

參數:

  • x,y – values to be compared.

    x,y –要比較的值。

Return value:

返回值:

The return type of this method is bool, it returns True if x is less than y, False, otherwise.

此方法的返回類型為bool ,如果x小于y ,則返回True ,否則返回False 。

Example 1:

范例1:

# Python operator.lt() Function Example
import operator
# integers
x = 10
y = 20
print("x:",x, ", y:",y)
print("operator.lt(x,y): ", operator.lt(x,y))
print("operator.lt(y,x): ", operator.lt(y,x))
print("operator.lt(x,x): ", operator.lt(x,x))
print("operator.lt(y,y): ", operator.lt(y,y))
print()
# strings
x = "Apple"
y = "Banana"
print("x:",x, ", y:",y)
print("operator.lt(x,y): ", operator.lt(x,y))
print("operator.lt(y,x): ", operator.lt(y,x))
print("operator.lt(x,x): ", operator.lt(x,x))
print("operator.lt(y,y): ", operator.lt(y,y))
print()
# printing the return type of the function
print("type((operator.lt(x,y)): ", type(operator.lt(x,y)))

Output:

輸出:

x: 10 , y: 20
operator.lt(x,y):  True
operator.lt(y,x):  False
operator.lt(x,x):  False
operator.lt(y,y):  False
x: Apple , y: Banana
operator.lt(x,y):  True
operator.lt(y,x):  False
operator.lt(x,x):  False
operator.lt(y,y):  False
type((operator.lt(x,y)):  <class 'bool'>

Example 2:

范例2:

# Python operator.lt() Function Example
import operator
# input two numbers
x = int(input("Enter first number : "))
y = int(input("Enter second number: "))
# printing the values
print("x:",x, ", y:",y)
# comparing
if operator.lt(x,y):
print(x, "is less than ", y)
else:
print(x, "is not less than ", y)

Output:

輸出:

RUN 1:
Enter first number : 10
Enter second number: 20
x: 10 , y: 20
10 is less than  20
RUN 2:
Enter first number : 20
Enter second number: 10
x: 20 , y: 10
20 is not less than  10

翻譯自: https://www.includehelp.com/python/operator-lt-function-with-examples.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541263.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541263.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541263.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

android實現滑動切換圖,Android:使用ViewPager實現左右滑動切換圖片加點點

圖片發自簡書App1、引入android-support-v4.jar包&#xff0c;在主布局里加入< ?xml version"1.0" encoding"utf-8"?>< RelativeLayout xmlns:android"http://schemas.android.com/apk/res/android"xmlns:tools"http://schemas.…

div的替代品

人們在標簽使用中最常見到的錯誤之一就是隨意將HTML5的<section>等價于<div>——具體地說&#xff0c;就是直接用作替代品(用于樣式)。在XHTML或者HTML4中&#xff0c;我們常看到這樣的代碼&#xff1a; <!-- HTML 4-style code --> <div id"wrapper…

threadgroup_Java ThreadGroup list()方法與示例

threadgroupThreadGroup類的list()方法 (ThreadGroup Class list() method) list() method is available in java.lang package. list()方法在java.lang包中可用。 list() method is used to list or display information (like name, priority, thread group, etc.) to the st…

html的柱狀圖去除右邊縱坐標,excel如何把次坐標軸逆序

excel2010設置水平坐標軸逆序類型,但垂直坐標軸刻設置水平坐標軸逆序且垂直坐標軸軸仍位于圖表左側的步驟是&#xff1a;打開帶有圖表的Excel工作表&#xff1b;在圖表區域的水平軸標簽位置雙擊鼠標左鍵&#xff0c;打開“設置坐標軸格式”&#xff1b;勾尋逆序類別”&#xff…

jhipster項目遷移websocket

2019獨角獸企業重金招聘Python工程師標準>>> 1、 在項目目錄下命令行安裝 兩個組件 bower install sockjs-client bower install stomp-websocket 2、在index.html 中加入組件js的引用 <script src"bower_components/sockjs-client/dist/sockjs.js">…

Java包hashCode()方法及示例

包類hashCode()方法 (Package Class hashCode() method) hashCode() method is available in java.lang package. hashCode()方法在java.lang包中可用。 hashCode() method is used to return the hashcode of the package calculated from the package name. hashCode()方法用…

html 圖片上放置按鈕,用CSS在圖片上再加一個小按鈕

很簡單的&#xff0c;嗯&#xff0c;就是要做成這樣的&#xff1a;用CSS&#xff0c;當然得用層了&#xff0c;就是在圖片上再加一個層&#xff0c;用來放那個按鈕&#xff0c;按鈕又有兩種方式可以放&#xff0c;一種是直接用圖片img標簽&#xff0c;一種是通過背景圖片放上去…

html點擊導航變色,點擊導航后,當前導航的顏色變色

html>Documentnav ul {padding: 0;list-style: none;}nav ul li {text-decoration: none;width: 70px;line-height: 50px;text-align: center;float: left;background-color: #000;color: #fff;cursor: pointer;}.gray {background-color: rgba(0,0,0,0.6);}首頁實戰路徑猿問…

Java掃描儀toString()方法及示例

掃描儀類toString()方法 (Scanner Class toString() method) toString() method is available in java.util package. toString()方法在java.util包中可用。 toString() method is used to string denotation of this Scanner and it contains information related to tracing.…

怎么將oracle的sql文件轉換成mysql的sql文件

怎么將sql文件導入PowerDesigner中的方法(將oracle的sql文件轉換成mysql的sql文件)呢&#xff1f; 怎么將xx.sql文件的數據庫結構導入powerdesigner 的方法呢? 現講下。 工具/原料 PowerDesigner軟件&#xff0c;oracle數據庫 方法/步驟 將要導入的庫的所有表的表結構(不要表數…

ios html圖片相對路徑,iOS 下加載本地HTML/js/css/image 等路徑問題

今天在項目中遇到一個問題&#xff1a;我將H5的文件拖入項目中&#xff0c;在webView上添加H5,運行時發現H5的樣式與圖片等都沒屏幕快照 2016-07-06 11.33.22.png有了。經過多種測試后發現&#xff1a;是路徑的問題。在ios項目下添加本地HTML/js/css/image 當拖入項目時有兩種選…

nextfloat_Java Random nextFloat()方法與示例

nextfloat隨機類nextFloat()方法 (Random Class nextFloat() method) nextFloat() method is available in java.util package. nextFloat()方法在java.util包中可用。 nextFloat() method is used to generate the next pseudo-random float value between the range 0.0 and …

mac自己定義tree命令

編輯文件: vim ~/.bash_profile 在文件末尾追加: alias tree"find . -print | sed -e s;[^/]*/;|____;g;s;____|; |;g" 應用配置: source ~/.bash_profile 轉載于:https://www.cnblogs.com/gavanwanggw/p/6962533.html

Java Hashtable keySet()方法與示例

哈希表類keySet()方法 (Hashtable Class keySet() method) keySet() method is available in java.util package. keySet()方法在java.util包中可用。 keySet() method is used to return a set of keys to be viewed in a set in this Hashtable. keySet()方法用于返回要在此H…

el-calendar 怎么設置上一年和下一年_為什么香港碩士一年的含金量那么高?

為什么香港碩士研究生只讀一年但含金量更高&#xff1f;近些年來香港留學大熱&#xff0c;其中一個原因就是香港的授課式碩士研究生僅需一年就可以拿到學位。對于學生來說&#xff0c;在享受到國際一流的教學資源和工作機會的同時&#xff0c;既節省時間又節約金錢&#xff0c;…

武漢市江岸區2021年高考成績查詢,2021年武漢各區一、二、三批次高中有哪些(名單)...

5月5日至9日是武漢市中考網上報名填報志愿的日子&#xff0c;填報志愿之前應提前了解本區的一批次、二批次和三批次學校的名單&#xff0c;了解其歷年錄取分數線&#xff0c;并選中最合適最理想的一所學校進行填寫&#xff0c;下面我們來看詳細名單。武漢各區一、二、三批次高中…

《Java設計模式》之橋接模式

Bridge模式的概念 Bridge 模式是構造型的設計模式之中的一個。Bridge模式基于類的最小設計原則&#xff0c;通過使用封裝&#xff0c;聚合以及繼承等行為來讓不同的類承擔不同的責任。它的主要特點是把抽象&#xff08;abstraction&#xff09;與行為實現&#xff08;implement…

Java Formatter locale()方法與示例

Formatter類的locale()方法 (Formatter Class locale() method) locale() method is available in java.util package. locale()方法在java.util包中可用。 locale() method is used to returns the locales assign by the construction of this Formatter. locale()方法用于返…

cad中tk什么意思_設計中的“Neobject”什么意思?來了解一下

DesignArchitectureInteriorsFashionArtTransportTHE STUFF THAT REFINES YOU破界造物New Language?“Neobject&#xff0c;言如其字&#xff0c;從語義上&#xff0c;前綴 neo- 表示新的&#xff0c;object 則是物體&#xff0c;是客觀存在&#xff0c;很中性&#xff0c;作動…

html文段源碼,HTML 段落

HTML 段落HTML 可以將文檔分割為若干段落。HTML 段落段落是通過 標簽定義的。實例這是一個段落這是另一個段落嘗試一下 注意&#xff1a;瀏覽器會自動地在段落的前后添加空行。( 是塊級元素)不要忘記結束標簽即使忘了使用結束標簽&#xff0c;大多數瀏覽器也會正確地將 HTML 顯…