浙大PTA 第6章函数-2 使用函数求素数和 (20 分)

PTA 浙大版《C语言程序设计(第3版)》题目集全套代码 PTA 浙大版《C语言程序设计(第3版)》题目集全套代码 Here is PTA网站地址 本文适合C语言初学者,风格轻松明快,语言简洁易懂。本文在实际 案例中插入知识点,因为C语言不是学会的,而是练会的。多做题, 多上手写代码才能早日晋级,离开新手村。 来吧!投入C语言的怀抱吧! 文章目录PTA 浙大版《C语言程序设计(第3版)》题目集全套代码前前言 怎样算是一个好的程序前言一、函数题1.练习5-1 求m到n之和2.找两个数中最大者二、编程题1.练习2-1 Programming in C is fun 阅读详情

使用函数求素数和

prime(p), 其中函数prime当用户传入参数p为素数时返回True,否则返回False. PrimeSum(m,n),函数PrimeSum返回区间[m, n]内所有素数的和。题目保证用户传入的参数1<=m<n。

函数接口定义:

在这里描述函数接口:
prime(p),返回True表示p是素数,返回False表示p不是素数
PrimeSum(m,n),函数返回素数和

裁判测试程序样例:


/* 请在这里填写答案 */

m,n=input().split()
m=int(m)
n=int(n)
print(PrimeSum(m,n))

输入样例:

在这里给出一组输入。例如:

1 10

输出样例:

在这里给出相应的输出。例如:

17

题解:

import math
def prime(num):
    if num==1:
        return False
    for i in range(2,int(math.sqrt(num))+1):
        if num%i==0:
            return False
    else:
        return True
def PrimeSum(m,n):
    sum=0
    for i in range(m,n+1):
        if prime(i):
            sum+=i
    return sum

 

【PTA】【浙大版《python程序设计》】6-2 使用函数求素数和 (20 分) 使用函数求素数和 prime§, 其中函数prime当用户传入参数p为素数时返回True,否则返回False. PrimeSum(m,n),函数PrimeSum返回区间[m, n]内所有素数的和。题目保证用户传入的参数1<=m<n。 函数接口定义: 在这里描述函数接口: prime§,返回True表示p是素数,返回False表示p不是素数 PrimeSum(m,n),函数返回素数和 裁... 阅读详情

相关推荐

PTA-浙大版《Python 程序设计》AC解答汇总

感谢点赞收藏~~~???? 编程题[第1章-1 从键盘输入两个数,求它们的和并输出 (30分)][第1章-2 从键盘输入三个数到a,b,c中,按公式值输出 (30分)] [第1章-3 输出“Python语言简单易学” (10分)] ...

卷子的博客 1万+

6-7 使用函数求素数和 (20 分)

本题要求实现一个判断素数的简单函数、以及利用该函数计算给定区间内素数和的函数。 素数就是只能被1和自身整除的正整数。注意:1不是素数,2是素数。 函数接口定义: int prime( int p ); int PrimeSum( int m, int n ); 其中函数prime当用户传入参数p为素数时返回1,否则返回0;函数PrimeSum返回区间[m,n]内所有素数的和。题目保证用户传入的参数m≤n。 裁判测试程序样例: #include <stdio.h> #includ.

qq_62781214的博客 8727

从DC到DCG:手把手教你搭建物理感知综合流程(含DEF文件处理避坑指南)

本文详细介绍了从Design Compiler(DC)过渡到DC Topographical(DCT)和DC Graphical(DCG)的完整操作框架,特别针对DEF文件处理提供避坑方案。通过环境准备、工具升级、DEF文件处理、DCG综合配置等步骤,帮助开发者高效应对28nm以下工艺节点的物理感知综合挑战,显著提升时序收敛效率。

weixin_27966471的博客 380

习题5-6 使用函数输出水仙花数 (20分)

水仙花数是指一个N位正整数(N≥3),它的每个位上的数字的N次幂之和等于它本身。例如:153=13+53+33。 本题要求编写两个函数,一个判断给定整数是否水仙花数,另一个按从小到大的顺序打印出给定区间(m,n)内所有的水仙花数。 函数接口定义: int narcissistic( int number ); void PrintN( int m, int n ); 函数narcissistic判断number是否为水仙花数,是则返回1,否则返回0。 函数PrintN则打印开区间(m, n)内所有的水仙花

MortyC99430的博客 1844

【DAY11】超参数调整专题1

核心优势: 它不是随机选择下一个点,而是根据先前评估的结果建立一个概率模型(通常是高斯过程),预测哪些参数组合可能产生更好的结果,并据此选择下一个评估点。这使得它在寻找最优解方面通常比随机搜索更高效(用更少的迭代次数达到相似或更好的性能),特别是当模型训练(单次评估)非常耗时的时候。实际上,有着非常多的方式可以实现贝叶斯优化,上面的代码比较简洁美观,贝叶斯优化和网格搜索的代码书写风格高度一致。- 需要定义参数的搜索空间,与随机搜索类似,当搜索空间非常大时,它通常比网格搜索和随机搜索更有效。

daomingwu1的博客 747

量化风控核心:信用评分卡模型的设计与迭代全流程

◦ 动态策略适配:根据评分卡结果动态调整风控流程——高分用户(>750分)秒级放款,中低分用户(600-700分)触发补充资料提交,低分用户(<600分)直接拒绝。◦ 特征有效性监控:每月计算特征IV值,对IV<0.1的低效特征(如“用户星座”)进行淘汰,同时引入新特征(如电商消费数据)。某城商行通过增量学习,评分卡PSI值长期稳定在0.1以下。◦ 数据筛选:整合征信数据(逾期记录、查询次数)、行为数据(消费频次、还款习惯),某银行评分卡纳入150+维度特征,覆盖用户偿债能力、意愿、稳定性等维度;

2501_91651383的博客 1483

6-8 使用函数求最大公约数 (10 分)

本题要求实现一个计算两个数的最大公约数的简单函数。 函数接口定义: int gcd( int x, int y ); 其中x和y是两个正整数,函数gcd应返回这两个数的最大公约数。 裁判测试程序样例: #include <stdio.h> int gcd( int x, int y ); int main() { int x, y; scanf("%d %d", &x, &y); printf("%d\n", gcd(x, y));

qq_40035365的博客 2216

Nginx源码安装和基础配置

Nginx简介 nginx: 世界第二大web服务器软件,以高并发、低消耗著称,源自于俄罗斯,创建者 Igor(伊戈尔),2004年开源,最早以代理服务器的身份出现,2015成立nginx公司,2019年以6.7亿被F5 Networks公司收购。 代理服务器: 正向:squid 反向: squid:最古老的代理服务器 LVS: 优点: 1.抗负载能力强、是工作在网络4层之上仅作分发之用 2.配置性比较低,这是一个缺点也是一个优点,简单不易出错 3.工作稳定,抗负载能力很强,有完整的双机热备方案

hjyhjy0的博客 500

浙大版《C语言程序设计(第3版)》题目集 习题5-4 使用函数求素数和 (20分)

#include <stdio.h> #include <math.h> int prime(int p); int PrimeSum(int m, int n); int main() { int m, n, p; scanf("%d %d", &m, &n); printf("Sum of ( "); for (p = ...

qq_44458489的博客 747

Android HCE实战:手把手教你用Kotlin实现NFC公交卡模拟(含完整APDU指令解析)

本文是一份Android HCE实战指南,详细讲解如何使用Kotlin实现NFC公交卡模拟。内容涵盖HCE服务搭建、APDU指令(如SELECT AID、GET PROCESSING OPTIONS)的完整解析与响应逻辑,并提供读卡器端测试代码,帮助开发者深入理解基于主机的卡模拟技术。

qsc901234567的博客 1117

JMeter 压测实战全教程

脚本结构:测试计划 → 线程组 → HTTP 请求 → 监听器运行方式:图形化调试,命令行生产压测核心指标:QPS、RT、错误率、CPU、GC。

weixin_48309090的博客 651

浙大 | PTA 习题5-4 使用函数求素数和 (20分)

本题要求实现一个判断素数的简单函数、以及利用该函数计算给定区间内素数和的函数。 素数就是只能被1和自身整除的正整数。注意:1不是素数,2是素数。 函数接口定义: int prime( int p ); int PrimeSum( int m, int n ); 其中函数prime当用户传入参数p为素数时返回1,否则返回0;函数PrimeSum返回区间[m, n]内所有素数的和。题目保证用户传入的...

赞美太阳的博客 1023

AD18 PCB模块的Copy

在PCB布局时,时常会将元器件先分模块进行排布,最后才会进行总体的布局,在局部布局的时候,想要移动一个模块的器件总是很麻烦,需要选中全部才能进行移动,有些时候还有选漏的情况,所以会将局部布局的模块把它看做一个整体进行移动,效果如下,元件,布线,铜皮,过孔以及元件编号的位置摆放都和源模块一模一样。4、再选中需要复用的模块内的元件,按照第3步的顺序排序,粘贴刚刚复制的Channel Offset参数。在PCB布局时,有多个模块原理图是一模一样的情况,我们可以只画一个模块,之后灵活应用模块,进行copy。

qq_53859658的博客 3237

浙大Python题目集 PTA解析

引言 业余学习python有两年多时间,中间进步最快的阶段是我兼职给学生讲python课,怎么讲好一个知识点、如何给学生布置合适的作业、评判学生作业和作业讲解都让我对自己所学的知识做了一个很好的梳理,编程能力也得到一定提升。看来最好的学习方法就是学以致用,不断逼着自己去产出一些东西,反过来就能更好地去学习。 为进一步加强自己的编程基本功,最近业余时间好好琢磨了浙大PTA的python习题,花了10天左右认真做了一遍,感觉有些收获。 现在用写博客的方式好好整理一下。第一次写博客,写的不好的地方慢慢改善。

amateur_python的博客 1万+

计算机网络实验报告实验七可靠传输TCP协议分析

计算机网络实验报告实验七可靠传输TCP协议分析

m0_56638814的博客 966

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

浙大PTA-Python题库 函数题(6-1~6-6)题解

题目列表 第六章函数 -1 使用函数求特殊a串数列和 给定两个均不超过9的正整数a和n,要求编写函数fn(a,n) 求a+aa+aaa++⋯+aa⋯aa(n个a)之和,fn须返回的是数列和 函数接口定义: fn(a,n) 其中 a 和 n 都是用户传入的参数。 a 的值在[1, 9]范围;n 是[1, 9]区间内的个位数。函数须返回级数和 裁判测试程序样例: /* 请在这里填写答案 */ a,b=input().split() s=fn(int(a),int(b)) print(s) 输入样例

zimuzi2019的博客 2万+

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

PTA 浙大版《C语言程序设计(第4版)》题目集 参考答案(函数题)

PTA 浙大版《C语言程序设计(第4版)》题目集 参考答案(函数题) 本答案配套详解教程专栏,欢迎订阅https://blog.youkuaiyun.com/weixin_40171190/category_12034686.html?spm=1001.2014.3001.5482

少侠PSY的博客 6万+

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【PTA|Python】浙大版《Python 程序设计》题目集:函数练习

前言 Hello!小伙伴! 非常感谢您阅读海轰的文章,倘若文中有错误的地方,欢迎您指出~   自我介绍 ଘ(੭ˊᵕˋ)੭ 昵称:海轰 标签:程序猿|C++选手|学生 简介:因C语言结识编程,随后转入计算机专业,有幸拿过国奖、省奖等,已保研。目前正在学习C++/Linux(真的真的太难了~) 学习经验:扎实基础 + 多做笔记 + 多敲代码 + 多思考 + 学好英语! 往期题目集 【PTA|Python】浙大版《Python 程序设计》题目集:第一章 【PTA|Python】浙大版《Python

海到无边天作岸 山登绝顶我为峰 1万+

浙大Python 第6章函数-2 使用函数求素数和 (20 分)

原题题目 代码实现 import math def prime(p): if(p==1):return False else: temp = int(math.sqrt(p)) for i in range(2,temp+1): if(p%i == 0):return False; return True; def PrimeSum(m,n): ret = 0 for i in range(m,

Love 6's Private Blog 1561

PTA习题5-4 使用函数求素数和 (20 分)

题目 本题要求实现一个判断素数的简单函数、以及利用该函数计算给定区间内素数和的函数。 素数就是只能被1和自身整除的正整数。注意:1不是素数,2是素数。 函数接口定义: int prime( int p ); int PrimeSum( int m, int n ); 其中函数prime当用户传入参数p为素数时返回1,否则返回0;函数PrimeSum返回区间[m, n]内所有素数的和。题目保证用户传入的参数m≤n。 裁判测试程序样例: #include <stdio.h> #include &l

weixin_45814366的博客 4190

PTA(浙大版《C语言程序设计(第3版)》题目集

PTA(浙大版《C语言程序设计(第3版)》题目集 学习C语言程序设计的PTA题目 目录PTA(浙大版《C语言程序设计(第3版)》题目集PTA(浙大版《C语言程序设计(第3版)》题目集) 习题2-1 求整数均值 (10 分)输入格式:输出格式:输入样例:输出样例:解题代码PTA(浙大版《C语言程序设计(第3版)》题目集) 习题2-2 阶梯电价 (15 分)输入格式:输出格式:输入样例1:输出样例1:输入样例2:输出样例2:解题代码PTA(浙大版《C语言程序设计(第3版)》题目集) 习题2-3 求平方与倒数

小宇的博客 2328

python第六章函数课后答案_浙大PTA-Python题库 函数题(6-1~6-6)题解

其他各章题解链接如下浙大PTA-Python题库 编程题第一章(1-1~1-3)题解https://blog.youkuaiyun.com/zimuzi2019/article/details/107020657浙大PTA-Python题库编程题 第二章(2.1~2.14)题解https://blog.youkuaiyun.com/zimuzi2019/article/details/106984549浙大PTA-Pyt...

weixin_39724748的博客 2060

PTA 浙大第四版 C语言练习

PTA 浙大版《C语言程序设计实验与习题指导(第4版)》

qq_44016148的博客 2837

浙大PTA-Python题库 编程题第四章(4-1~4-30)题解

其他各章题解链接如下 浙大PTA-Python题库 编程题第一章(1-1~1-3)题解 https://blog.youkuaiyun.com/zimuzi2019/article/details/107020657 浙大PTA-Python题库编程题 第二章(2.1~2.14)题解 https://blog.youkuaiyun.com/zimuzi2019/article/details/106984549 浙大PTA-Python题库 编程题第三章(3-1~3-22)题解 https://blog.youkuaiyun.com/zimu

zimuzi2019的博客 7万+

浙大PTA 第4章-11 判断素数 (20 分)

判断一个给定的正整数是否素数 输入格式: 输入在第一行给出一个正整数N(≤ 10),随后N行,每行给出一个小于1000000 的需要判断的正整数 输出格式: 对每个需要判断的正整数,如果它是素数,则在一行中输出Yes,否则输出No 输入样例: 在这里给出一组输入。例如: 2 11 111 输出样例: 在这里给出相应的输出。例如: Yes No 题解: import math def is_prime(num): for i in range(2,int(math.sqr

amateur_python的博客 1815

浙江大学pta答案python函数题_荐浙大PTA-Python题库 函数题(6-1~6-6)题解

注:第七章只有一道题,因为正则表达式学校尚不要求我就还没看,所以这道题解的链接是另一个大佬的题目列表第六章函数 -1 使用函数求特殊a串数列和给定两个均不超过9的正整数a和n,要求编写函数fn(a,n) 求a+aa+aaa++⋯+aa⋯aa(n个a)之和,fn须返回的是数列和函数接口定义:fn(a,n)其中 a 和 n 都是用户传入的参数。 a 的值在[1, 9]范围;n 是[1, 9]区间内的个...

weixin_39927158的博客 2019
上一篇: 浙大PTA 第6章函数-1 使用函数求特殊a串数列和 (10 分)
下一篇: 浙大PTA 第6章函数-3 使用函数统计指定数字的个数 (20 分)
amateur_python
博客等级 码龄5年 118粉丝 94原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值