博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python中divmod_divmod()函数以及Python中的示例
阅读量:2556 次
发布时间:2019-05-11

本文共 1378 字,大约阅读时间需要 4 分钟。

python中divmod

Python divmod()函数 (Python divmod() function)

divmod() function is a library function, it is used to get the quotient and remainder of given values (dividend and divisor), it accepts two arguments 1) dividend and 2) divisor and returns a tuple that contains quotient and remainder.

divmod()函数是一个库函数,用于获取给定值的商和余数 ( 被除数和除数 ),它接受两个参数1) 除数和2) 除数,并返回一个包含商和余数的元组。

Syntax:

句法:

divmod(dividend, divisor)

Parameter(s):

参数:

  • dividend – a number to be divided.

    红利 –要除的数字。

  • divisor – a number to be divided with.

    除数 –要除的数字。

Return value: tuple – it returns a tuple containing quotient and remainder.

返回值: tuple –返回包含商和余数的元组。

Example:

例:

Input:    a = 10  #dividend    b = 3   #divisor    # finding quotient and remainder    result = divmod(a,b)    print("result = ", result)        Output:    result =  (3, 1)

Python code to find quotient and remainder of two numbers

Python代码查找两个数字的商和余数

# python code to demonstrate example of # divmod() numbera = 10  #dividendb = 3   #divisorprint("return type of divmod() function: ", type(divmod(a,b)))# finding quotient and remainderresult = divmod(a,b)print("result = ", result)# float valuesa = 10.23  #dividendb = 3.12   #divisor# finding quotient and remainderresult = divmod(a,b)print("result = ", result)

Output

输出量

return type of divmod() function:  
result = (3, 1)result = (3.0, 0.8700000000000001)

翻译自:

python中divmod

转载地址:http://auxzd.baihongyu.com/

你可能感兴趣的文章
小D课堂 - 零基础入门SpringBoot2.X到实战_第8节 数据库操作之整合Mybaties和事务讲解_35、事务介绍和常见的隔离级别,传播行为...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第9节 SpringBoot2.x整合Redis实战_40、Redis工具类封装讲解和实战...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第9节 SpringBoot2.x整合Redis实战_37、分布式缓存Redis介绍...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第10节 SpringBoot整合定时任务和异步任务处理_42、SpringBoot常用定时任务配置实战...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第9节 SpringBoot2.x整合Redis实战_39、SpringBoot2.x整合redis实战讲解...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第14节 高级篇幅之SpringBoot多环境配置_59、SpringBoot多环境配置介绍和项目实战...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第10节 SpringBoot整合定时任务和异步任务处理_41、SpringBoot定时任务schedule讲解...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第10节 SpringBoot整合定时任务和异步任务处理_43、SpringBoot2.x异步任务实战(核心知识)...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_1_01课程简介
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第11节 Logback日志框架介绍和SpringBoot整合实战_45、SpringBoot2.x日志讲解和Logback配置实战...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_1_02技术选型
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_汇总
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_2_01传统架构演进到分布式架构
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_2_02 微服务核心基础讲解
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_2_04微服务下电商项目基础模块设计...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_3-01 什么是微服务的注册中心
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_3-03CAP原理、常见面试题
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_3-04 SpringCloud微服务核心组件Eureka介绍和闭源后影响...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_3-05 服务注册和发现Eureka Server搭建实战...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_3-06 服务注册和发现之Eureka Client搭建商品服务实战...
查看>>