《计算机导论》实验报告 1、2_第1页
《计算机导论》实验报告 1、2_第2页
《计算机导论》实验报告 1、2_第3页
《计算机导论》实验报告 1、2_第4页
《计算机导论》实验报告 1、2_第5页
已阅读5页,还剩15页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

《计算机导论》实验报告第一学期系别:计算机科学与技术系班级:姓名:学号:指导教师:实验一Windows操作系统安装一、实验目的1.掌握硬盘的分区与格式化等操作。2.掌握windows操作系统的安装方法及步骤。3.熟悉VMware虚拟机软件的使用二、实验内容1.创建一个新的虚拟机环境作为后继实验平台。(1)双击桌面“MicrosoftVirtualPC”图标,打开VirtualPC虚拟机软件。(2)在VirtualPC菜单中选择“文件”—>“新建虚拟机向导”,进入“欢迎使用新建虚拟机向导”对话框,点击下一步,选择“新建一台虚拟机”,指定虚拟机的名称和位置,操作系统选择“WindowsXP”,使用推荐(或更改分配)内存大小,选择新建虚拟硬盘,指定名称和位置,创建完成。(3)运行虚拟机,在“CD(C)”菜单中载入ISO映像,指定一个有效的WindowsXP安装盘的镜像文件。2.在新建虚拟机中,使用PartitionMagic分区软件对硬盘进行合理的分区操作。(1)启动新建的WindowsXP虚拟机平台。(2)选择光盘启动菜单中的“PQ8-图形分区软件”选项,进入PartitionMagic分区软件。(3)将硬盘分为:主分区,在扩展分区中建立两个逻辑驱动器。具体步骤如下:①、先选定主磁盘C盘,选取FAT32格式进行格式化,再分配总存储空间的一半约30G给C盘,②再建立两个逻辑分割磁D盘和E盘,将余下的储存空间合理分配后再用FAT32格式进行格式化,③单击执行命令,执行上述操作。(结果如图)3.安装WindowsXP系统:(1)重新启动WindowsXP虚拟机平台后,选择光盘启动菜单中的“WINXPSP3精简安装版”选项,进入WindowsXP系统安装过程。(2)具体安装过程如下:①“WINXPSP3精简安装版”选项,按下ENTER键,进入WindowsXP系统安装过程,②等待约39分钟,让系统进行文件读取及安装;③安装完毕后,重启这台虚拟机即可。(结果如图)三、实验过程中遇到的问题及解决方法遇到的问题:①安装虚拟机时鼠标不能正常使用;②等待一段时间后,安装进程不变且停止解决方法:①由于虚拟机时鼠标不能正常使用,应用键盘进行操作,使用键盘操作后正行进行安装;②重新将数据复位即可。四、附:1、创建的WindowsXP虚拟机平台的截图。2、使用PartitionMagic分区软件对硬盘进行分区操作后的硬盘状态截图。3、WindowsXP系统安装完毕后首个桌面状态截图。.实验二Word2003文字处理软件一、实验目的1.掌握文档的输入与编辑、格式设置等操作。2.掌握表格的创建与编辑操作。3.掌握图文混排与公式的输入操作。二、实验内容1.输入文本(见实验指导书第88页),完成如下操作(1)文章标题设为宋体、小四号字、加粗和剧中。(2)正文中文设为楷体,英文设置过、英文设置为TimesNewRoman字体,五号字,段落首行缩进2字符,左右各缩进1字符。(3)段落的段前段后均为0行,1.5倍行距。(4)页面设置上下页边距为2cm,左右页边距为1.5cm,纸型为A4.(5)页眉内容设置为“前辈先哲”,宋体,五号,居中。(6)将文本中的“兔”字替换为“猫”。(7)编辑完成后,命名为“实验3.1.doc”,保存在“我的文档”中。2.创建如下表格(见实验指导书第89页),格式要求如下:(1)表的标题为宋体,小五号,黑体,居中。(2)表内文字为宋体,小五号,水平居中,垂直居中。(3)计算总成绩(考试成绩+平时成绩)。(4)表格外边框为1.5倍实线,内框为1磅实线,整个表格居中。3.制作如下文档(实验指导书第90页),格式说明如下:(1)艺术字标题为32号字体。(2)文字为五号楷体。(3)首字下沉3行,距正文0行。(4)图片环绕方式为“四周型”。三、实验过程中遇到的问题及解决方法遇到的问题:1.页眉中插入文字不成功;2.表格中总成绩计算错误;3.word操作中文字替换不成功;4.文字环绕方式设置不成功。解决方法:1.由于未选定位置,重新选定位置再插入;2.重新选区函数后计算正确;3.替换文字未输入,重新输入替换文字后替换成功;4.在编辑环境下待鼠标箭头呈十字架箭头时移动图片即可。四、附:实验文档打印

实验三Excel2003电子表格处理软件一、实验目的1.掌握Excel工作簿的建立与保存方法。2.掌握Excel中公式与函数的使用。3.掌握Excel中制作饼图的方法。4.掌握Excel中管理数据的方法。二、实验内容1.创建工作表(实验指导书第125页)2.制作饼图(见实验指导书第126页),要求如下:(1)图中文字部分设置为黑体、字形倾斜、12号字、颜色为红色。(2)图形边框为无色、背景为黄色、饼图全为绿色。(3)标题为“数计学院教师职称结构图”,显示名称和百分比。数据为:教授20%;副教授30%;讲师30%;助教20%。3.数据源如4.74所示(实验指导书第126页),并完成如下要求:(1)填充“总人数”。利用公式计算总人数:总人数=课容量-课余量。(2)填充“具体时间”。说明:“具体时间”填充时需要参考“日期”和“节次”,例如,“星期5,第3大节”的“具体时间”要表示成“53”,其余以此类推。(3)按照“具体时间”为主要关键字,“课程名称”为次要关键字全部降序排序(4)将“具体时间”为“71”的单元格背景改为红色。(5)将“具体时间”为“72”的单元格背景改为蓝色三、实验过程中遇到的问题及解决方法遇到的问题:①制作饼状图时,数据不能插入;②单元格背景设置不成功;③表格数据计算时,运用函数计算结果不正确解决方法:①由于未选中数据插入位置,重新选定位置在插入即可;②由于设置标颜色签选定错误,重新选定颜色再设置;③由于选取函数错误,重新正确选取函数即可。四、附:实验文档打印实验过程题目:Theareaofarectangleis

wh,where

w

and

h

arethelengthsofitssides.Notethatthemultiplicationoperationisnotshownexplicitlyinthisformula.Thisisstandardpracticeinmathematics,butnotinprogramming.WriteaPythonstatementthatcalculatesandprintstheareainsquareinchesofarectanglewithsidesoflength

4

and

7

inches.代码:print4*7运行结果:题目:Thecircumferenceofacircleis

2πr

where

r

istheradiusofthecircle.WriteaPythonstatementthatcalculatesandprintsthecircumferenceininchesofacirclewhoseradiusis

8

inches.Assumethattheconstant

π=3.14.代码:print2*3.14*8运行结果:题目:Theareaofacircleis

πr2

where

r

istheradiusofthecircle.(Theraised

2

intheformulaisanexponent.)WriteaPythonstatementthatcalculatesandprintstheareainsquareinchesofacirclewhoseradiusis

8

inches.Assumethattheconstant

π=3.14.代码:print3.14*8**2运行结果:题目:Given

p

dollars,thefuturevalueofthismoneywhencompoundedyearlyatarateof

r

percentinterestfor

y

yearsis

p(1+0.01r)y.WriteaPythonstatementthatcalculatesandprintsthevalueof

1000

dollarscompoundedat

7

percentinterestfor

10

years.代码:print1000*(1+0.01*7)**10或a=1c=1b=(1+0.01*7)p=1000whilea<=10:c=c*ba=a+1p=p*cprintp运行结果:题目:WriteasinglePythonstatementthatcombinesthethreestrings

"Mynameis",

"Joe"

and

"Warren"

(plusacoupleofothersmallstrings)intoonelargerstring

"MynameisJoeWarren."

andprintstheresult.代码:print"Mynameis"+"Joe"+""+"Warren"+"."运行结果:题目:WriteaPythonexpressionthatcombinesthestring

"JoeWarrenis52yearsold."

fromthestring

"JoeWarren"

andthenumber

52

andthenprintstheresult(Hint:Usethefunction

str

toconvertthenumberintoastring.)代码:print"JoeWarren"+"is"+str(52)+"yearsold."运行结果:题目:Thedistancebetweentwopoints

(x0,y0)

and

(x1,y1)

is

√(x0-x1)2+(y0-y1)2

代码:print((2-5)**2+(2-6)**2)**0.5或a=(2-5)*(2-5)+(2-6)*(2-6)printpow(a,0.5)运行结果:WriteaPythonfunction

is_lunchtime

thattakesasinputtheparameters

hour

(anintegerintherange

[1,12])and

is_am

(aBoolean“flag”thatrepresentswhetherthehourisbeforenoon).Thefunctionshouldreturn

True

whentheinputcorrespondsto11amor12pm(noon)and

Falseotherwise.Iftheproblemspecificationisunclear,lookatthetestcasesintheprovidedtemplate.Oursolutiondoesnotuseconditionalstatements.代码:defis_lunchtime(hour,is_am): """ Returnswhetherthegiventime,asrepresentedbythehour andis_am,islunchtime. """ return(hour==11andis_am)or(hour==12andnotis_am)deftest(hour,is_am): """Teststheis_lunchtimefunction.""" printhour, ifis_am: print"AM", else: print"PM", ifis_lunchtime(hour,is_am): print"islunchtime." else: print"isnotlunchtime."test(11,True)test(12,True)test(11,False)test(12,False)test(10,False)运行结果:WriteaPythonfunction

is_leap_year

thattakeasinputtheparameter

year

andreturns

True

if

year

(aninteger)isaleapyearaccordingtotheGregoriancalendarand

False

otherwise.TheWikipediaentryfor

leapyears

containsasimplealgorithmicrulefordeterminingwhetherayearisaleapyear.YourmaintaskwillbetotranslatethisruleintoPython.代码:defis_leap_year(year): """ ReturnswhetherthegivenGregorianyearisaleapyear. """ return((year%4)==0and((year%100)!=0or(year%400)==0))deftest(year): """Teststheis_leapyearfunction.""" ifis_leap_year(year): printyear,"isaleapyear." else: printyear,"isnotaleapyear."test(2000)test(1996)test(1800)test(2013)运行结果:WriteaPythonfunction

interval_intersect

thattakesparameters

a,

b,

c,and

d

andreturns

True

iftheintervals

[a,b]

and

[c,d]

intersectandFalse

otherwise.Whilethistestmayseemtricky,thesolutionisactuallyverysimpleandconsistsofonelineofPythoncode.(Youmayassumethat

a≤b

and

c≤d.)代码:definterval_intersect(a,b,c,d):"""Returnswhethertheintervals[a,b]and[c,d]intersect."""return(c<=b)and(a<=d)deftest(a,b,c,d):"""Teststheinterval_intersectfunction."""print"Intervals["+str(a)+","+str(b)+"]and["+str(c)+","+str(d)+"]",ifinterval_intersect(a,b,c,d):print"intersect."else:print"donotintersect."test(0,1,1,2)test(1,2,0,1)test(0,1,2,3)test(2,3,0,1)test(0,3,1,2)运行结果:WriteaPythonfunction

name_and_age

thattakeasinputtheparameters

name

(astring)and

age

(anumber)andreturnsastringoftheform

"%is%yearsold."

wherethepercentsarethestringformsof

name

and

age.Thefunctionshouldincludeanerrorcheckforthecasewhen

age

islessthanzero.Inthiscase,thefunctionshouldreturnthestring

"Error:Invalidage".代码:defname_and_age(name,age): """Returnsastringstatingtheperson'sage.""" ifage>=0: returnname+"is"+str(age)+"yearsold." else: return"Error:Invalidage"deftest(name,age): """Teststhename_and_agefunction.""" printname_and_age(name,age) test("JoeWarren",52)test("ScottRixner",40)test("JohnGreiner",-46)运行结果:WriteaPythonfunction

print_digits

thattakesaninteger

number

intherange

[0,100)

andprintsthemessage

"Thetensdigitis%andtheonesdigitsis%"

wherethepercentsshouldbereplacedwiththeappropriatevalues.Thefunctionshouldincludeanerrorcheckforthecasewhend

isnegativeorgreaterthanorequalto

100.Inthosecases,thefunctionshouldinsteadprint

"Error:Inputisnotatwo-digitnumber.".代码:defprint_digits(number): """Printsthetensandonesdigitofanintegerin[0,100).""" if0<=number<100: print"Thetensdigitis"+str(number//10)+",", print"andtheonesdigitis"+str(number%10)+"." else: print"Error:Inputisnotatwo-digitnumber." print_digits(42)print_digits(99)print_digits(5)print_digits(459)运行结果:WriteaPythonfunction

name_lookup

thattakesastring

first_name

thatcorrespondstooneof("Joe",

"Scott",

"John"

or

"Stephen")andthenreturnstheircorrespondinglastname("Warren",

"Rixner",

"Greiner"

or

"Wong").If

first_name

doesn'tmatchanyofthosestrings,returnthestring

"Error:Notaninstructor".代码:defname_lookup(first_name): """Returnstheinstructor'slastname.""" iffirst_name=="Joe": return"Warren" eliffirst_name=="Scott": return"Rixner" eliffirst_name=="John": return"Greiner" eliffirst_name=="Stephen": return"Wong" else: return"Error:Notaninstructor"deftest(first_name): """Teststhename_lookupfunction.""" printname_lookup(first_name) test("Joe")test("Scott")test("John")test("Stephen")test("Mary")运行结果:PigLatin

isalanguagegamethatinvolvesalteringwordsviaasimplesetofrules.WriteaPythonfunction

pig_latin

thattakesastring

word

andappliesthefollowingrulestogenerateanewwordinPigLatin.Ifthefirstletterin

word

isaconsonant,appendtheconsonantplus

"ay"

totheendoftheremainderoftheword.Forexample,

pig_latin("pig")wouldreturn

"igpay".Ifthefirstletterin

word

isavowel,append

"way"

totheendoftheword.Forexample,

pig_latin("owl")

returns

"owlway".Youcanassumethat

word

isinlowercase.Theprovidedtemplateincludescodetoextractthefirstletterandtherestof

word

inPython.Notethat,infullPigLatin,theleadingconsonantclusterismovedtotheendoftheword.However,wedon'tknowenoughPythontoimplementfullPigLatinjustyet.代码:defpig_latin(word): """Returnsthe(simplified)PigLatinversionoftheword.""" first_letter=word[0] rest_of_word=word[1:] #Studentshouldcompletefunctiononthenextlines. if(first_letter=="a"orfirst_letter=="e"orfirst_letter=="i"or first_letter=="o"orfirst_letter=="u"): returnword+"way" else: returnrest_of_word+first_letter+"ay"deftest(word): """Teststhepig_latinfunction.""" printpig_latin(word) test("pig")test("owl")test("python")运行结果:Challenge:

Givennumbers

a,

b,and

c,the

quadraticequation

ax2+bx+c=0

canhavezero,oneortworealsolutions(i.e;valuesfor

x

thatsatisfytheequation).The

quadraticformulax=−b±b2−4ac√2acanbeusedtocomputethesesolutions.Theexpression

b2−4ac

isthe

discriminant

associatedwiththeequation.Ifthediscriminantispositive,theequationhastwosolutions.Ifthediscriminantiszero,theequationhasonesolution.Finally,ifthediscriminantisnegative,theequationhasnosolutions.WriteaPythonfunction

smaller_root

thattakesaninputthenumbers

a,

b

and

c

andreturnsthesmallersolutiontothisequationifoneexists.Iftheequationhasnorealsolution,printthemessage

"Error:Norealsolutions"

andsimplyreturn.Notethat,inthiscase,thefunctionwillactuallyreturnthespecialPythonvalue

None.代码:defsmaller_root(a,b,c):"""Returnsthesmallerrootofaquadraticequationwiththegivencoefficients."""discriminant=b**2-4*a*cifdiscriminant<0ora==0:print"Error:Norealsolutions"else:discriminant_sqrt=discriminant**0.5#Choosethepositiveornegativesquarerootthatleadstoasmallerroot.ifa>0:smaller=-discriminant_sqrtelse:smaller=discriminant_sqrtreturn(-b+smaller)/(2*a)deftest(a,b,c):"""Teststhesmaller_rootfunction."""print"Thesmallerrootof"+str(a)+"x^2+"+str(b)+"x+"+str(c)+"is:"printstr(smaller_root(a,b,c))test(1,2,3)test(2,0,-10)test(6,-3,5)运行结果:计算1+2+3+。。。+100代码:sum=0i=1whilei<=100:sum=sum+ii=i+1printsum运行结果:计算1*2*3*4*5*。。。n代码:p=1i=1n=int(raw_input('Enteraninteger:'))whilei<=n:p=p*ii=i+1printp运行结果:计算任意个整数之和代码:s=0i=1n=int(raw_input('Enteraninteger:'))whilei<=n:x=int(raw_input('Enteraninteger:'))s=s+xi=i+1prints运行结果:实验体会需要注意哪些细节?你在实验中有哪些问题未解决?结论:自我评价:签名:日期:实验过程题目:Theareaofarectangleis

wh,where

w

and

h

arethelengthsofitssides.Notethatthemultiplicationoperationisnotshownexplicitlyinthisformula.Thisisstandardpracticeinmathematics,butnotinprogramming.WriteaPythonstatementthatcalculatesandprintstheareainsquareinchesofarectanglewithsidesoflength

4

and

7

inches.代码:运行结果:题目:Thecircumferenceofacircleis

2πr

where

r

istheradiusofthecircle.WriteaPythonstatementthatcalculatesandprintsthecircumferenceininchesofacirclewhoseradiusis

8

inches.Assumethattheconstant

π=3.14.代码:运行结果:题目:Theareaofacircleis

πr2

where

r

istheradiusofthecircle.(Theraised

2

intheformulaisanexponent.)WriteaPythonstatementthatcalculatesandprintstheareainsquareinchesofacirclewhoseradiusis

8

inches.Assumethattheconstant

π=3.14.代码:运行结果:题目:Given

p

dollars,thefuturevalueofthismoneywhencompoundedyearlyatarateof

r

percentinterestfor

y

yearsis

p(1+0.01r)y.WriteaPythonstatementthatcalculatesandprintsthevalueof

1000

dollarscompoundedat

7

percentinterestfor

10

years.代码:运行结果:题目:WriteasinglePythonstatementthatcombinesthethreestrings

"Mynameis",

"Joe"

and

"Warren"

(plusacoupleofothersmallstrings)intoonelargerstring

"MynameisJoeWarren."

andprintstheresult.代码:运行结果:题目:WriteaPythonexpressionthatcombinesthestring

"JoeWarrenis52yearsold."

fromthestring

"JoeWarren"

andthenumber

52

andthenprintstheresult(Hint:Usethefunction

str

toconvertthenumberintoastring.)代码:运行结果:题目:Thedistancebetweentwopoints

(x0,y0)

and

(x1,y1)

is

√(x0-x1)2+(y0-y1)2

代码:运行结果:WriteaPythonfunction

is_lunchtime

thattakesasinputtheparameters

hour

(anintegerintherange

[1,12])and

is_am

(aBoolean“flag”thatrepresentswhetherthehourisbeforenoon).Thefunctionshouldreturn

True

whentheinputcorrespondsto11amor12pm(noon)and

Falseotherwise.Iftheproblemspecificationisunclear,lookatthetestcasesintheprovidedtemplate.Oursolutiondoesnotuseconditionalstatements.代码:运行结果:WriteaPythonfunction

is_leap_year

thattakeasinputtheparameter

year

andreturns

True

if

year

(aninteger)isaleapyearaccordingtotheGregoriancalendarand

False

otherwise.TheWikipediaentryfor

leapyears

containsasimplealgorithmicrulefordeterminingwhetherayearisaleapyear.YourmaintaskwillbetotranslatethisruleintoPython.代码:运行结果:WriteaPythonfunction

interval_intersect

thattakesparameters

a,

b,

c,and

d

andreturns

True

iftheintervals

[a,b]

and

[c,d]

intersectandFalse

otherwise.Whilethistestmayseemtricky,thesolutionisactuallyverysimpleandconsistsofonelineofPythoncode.(Youmayassumethat

a≤b

and

c≤d.)代码:运行结果:WriteaPythonfunction

name_and_age

thattakeasinputtheparameters

name

(astring)and

age

(anumber)andreturnsastringoftheform

"%is%yearsold."

wherethepercentsarethestringformsof

name

and

age.Thefunctionshouldincludeanerrorcheckforthecasewhen

age

islessthanzero.Inthiscase,thefunctionshouldreturnthestring

"Error:Invalidage".代码:运行结果:WriteaPythonfunction

print_digits

thattakesaninteger

number

intherange

[0,100)

andprintsthemessage

"Thetensdigitis%andtheonesdigitsis%"

wherethepercentsshouldbereplacedwiththeappropriatevalues.Thefunctionshouldincludeanerrorcheckforthecasewhend

isnegativeorgreaterthanorequalto

100.Inthosecases,thefunctionshouldinsteadprint

"Error:Inputisnotatwo-digitnumber.".代码:运行结果:WriteaPythonfunction

name_lookup

thattakesastring

first_name

thatcorrespondstooneof("Joe",

"Scott",

"John"

or

"Stephen")andthenreturnstheircorrespondinglastname("Warren",

"Rixner",

"Greiner"

or

"Wong").If

first_name

doesn'tmatchanyofthosestrings,re

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论