| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1039 人关注过本帖
标题:【求助】求大神帮忙python的作业
取消只看楼主 加入收藏
huiyang90
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2012-11-10
收藏
 问题点数:0 回复次数:5 
【求助】求大神帮忙python的作业
求各位大神帮忙,本人电脑白痴一枚,更别提编程了。
光是CPU和RAM就花了2天才弄明白是什么东西..
废话不多说..
我要用python写作业,
第一份,
要用pickAFile选择文件,然后可以辨别文件是不是图片(jpg格式)或者用makeSound选择辨别是不是wav格式的声音。
如果两者皆不是又要辨别出是哪一种文件格式。如果文件名字有错误(比如果说1234jpg,漏了点要有信息提示说有错误)
最后教授还提到什么rfind的东西,还有什么是len function
这是教授给的结果:
>>> openSoundOrPicture()
Oops! Did not choose a picture or a sound file.
Type is: html
搜索更多相关主题的帖子: function python 天才 
2012-11-10 04:55
huiyang90
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2012-11-10
收藏
得分:0 
作业题目原文,我解释的还行吧..
A fairly simple function is required that will obtain a file name (using pickAFile), and then recognise if it is a picture or a sound file, or even some other file type. The file should then be interpreted as either a picture—if of type jpg (then call makePicture, display the picture then exit) or a sound—if of type wav (then call makeSound, play the sound then exit) and if it is neither a picture nor a sound file, then an error message must be printed. This error message should include the type of the file (or the lack of a type, e.g. a file name that might not have a period in it, e.g.ducksjpg). Remember that file types can be 2, 3, 4 or even more letters long! The rfind method (see page 250) is useful here, as is the lenfunction. Don't open any files using file.open!
Typical output for attempting to access a file of type 'html' would be:
>>> openSoundOrPicture()
Oops! Did not choose a picture or a sound file.
Type is: html
NOTE: For submission, demonstrate your function by attempting to open a file of type 'html', and capture the output.
2012-11-10 04:56
huiyang90
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2012-11-10
收藏
得分:0 
第二份题目:

(请容我慢慢的看题目)

We will build on the functions provided to you in Lab 6. What is needed is a program that will attempt to smooth out the random noise present in a noisy sound file firstly by averaging two consecutive samples and then secondly by averaging three consecutive samples.

Write a program that will:

Using the functions from Lab 6, create a noisy sound by adding random noise to this sound file, but implement appropriate changes so that the given functions can be called by a main or calling program.
In the main program, adjust this noisy sound by creating a new current value, for each sample, based on the average of the previous sample and the current sample. The first sample can be averaged with an initial value of 0 for the "previous sample."
Now adjust the the same original noisy sound in part 1 by creating a new current value, for each sample, based on the average of the previoustwo samples and the current sample.The first sample can be averaged with an initial value of 0 for both the "previous samples."
In order to 'see' the sounds produced, invoke the function openSoundTool(sound) three times within your program, displaying the original noisy sound, then the smoothed sound from 2., and then finally the smoothed sound from 3. (There is no need to return any sound from the main/calling program.) For interest, here is a picture of the three windows, but tiled for convenience. Please press the 'Zoom In' button on each Sound Tool window, and ensure that the index is at 1 before copying the window, as this makes it easier to mark!
For submission, a single execution of your program could be:
>>> smoothSound(file, 2500)
where 'file' is the same sound file used in the lab 6, and the value of 2500 is the maximum amplitude for the added noise. For your submission, capture the output (Zoomed in, index at 1), in order, of the three invocations of the Sound Tool.
2012-11-10 04:57
huiyang90
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2012-11-10
收藏
得分:0 
def randomNoise():
import random
maxAmp = 2500 #Not too loud!
noisy = makeEmptySound(10000)
for s in getSamples(noisy):
setSample(s, random.randrange(-maxAmp, maxAmp+1))

play (noisy)

这个是教授提供的,要在这个基础上变动
题目要求要有音量的变动,第一个声音要求是average....
额..我真心看不懂他要我干嘛..
麻烦教我怎么在这个程序的基础上更改能让一个声音越来越小声!
谢谢啦!
2012-11-10 04:58
huiyang90
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2012-11-10
收藏
得分:0 
[local]1[/local][local]2[/local]

不知道这图片有没有帮助
2012-11-10 04:58
huiyang90
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2012-11-10
收藏
得分:0 
好吧,图片好像不行..

LL真心束手无策了,才来求各位大神帮忙的..
学校骗人!明明说好学这课不需要任何的电脑背景的!可是望眼过去一个个都是主修电脑编程的!
这让主修会计的我情何以堪啊!

拜托拜托!!
2012-11-10 05:00
快速回复:【求助】求大神帮忙python的作业
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024050 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved