考慮到自己學(xué)習(xí)是在是沒有方向,不知道怎么系統(tǒng)去學(xué)。
同時(shí)也確實(shí)有一些數(shù)據(jù)分析崗位需要的知識沒有掌握,決定報(bào)了一個(gè)班。
今天做了一套測試題,認(rèn)識到自己很多東西沒有運(yùn)用都忘了。
想想自己才剛畢業(yè)7個(gè)多月,還是學(xué)的IT專業(yè)有點(diǎn)慚愧。
為了以后好好努力吧。
附上測試題以及筆記:
SQL:
基礎(chǔ)檢測部分:
- 查詢在 SC 表存在成績的學(xué)生信息,要求顯示學(xué)號id、姓名、出生年月、性別、課程id、分?jǐn)?shù)(10分)
【一次過】
select s.SId,s.Sname,s.Sage,s.Ssex,c.CId,c.score
from Student s right join SC c
on s.SId=c.SId;
答案
select
a.*,
b.*
from student a
inner join sc b
on a.sid=b.sid;
不會用 table.*
- 查詢各個(gè)同學(xué)的總成績和平均分(10分)
【一次過】
select s.SId,s.Sname,sum(c.score),avg(c.score) from
Student s right join SC c
on s.SId=c.SId
group by s.SId,s.Sname;
- 查詢每門課都有幾個(gè)學(xué)生(10分)
select c.CId,c.Cname,count(SC.score)
from Course c
join SC
on c.CId=SC.CId
group by c.CId,c.Cname;
第一次做的時(shí)候忘了用on
- 查詢同時(shí)存在"01"課程和"02"課程的學(xué)生情況 (10分)
不會,附上答案
select
*
from sc a
inner join sc b
on a.sid=b.sid and a.cid='01' and b.cid='02';
知識漏洞:一個(gè)表的自連接
- 查詢「李」姓老師的數(shù)量(like的用法)(20分)
select count(Tid)
from Teacher
where Tname like "李%";
- 查詢平均成績大于等于60分的同學(xué)的學(xué)生編號和學(xué)生姓名和平均成績(20分)
select s.SId, s.Sname, avg(SC.score) as avgScore
from Student s
join SC
on s.Sid=SC.SId
group by s.SId, s.Sname
having avgScore>=60;
- 查詢"01"課程比"02"課程成績高的學(xué)生的信息及課程分?jǐn)?shù) (20分)
【錯(cuò)】
select * from
(select * from Student join SC on Student.SId=SC.SId where SC.CId="01") sone
join
(select * from Student join SC on Student.SId=SC.SId where SC.CId="02") stwo
on sone.Sid=stwo.Sid
where sone.score>stwo.score;
select
*
from sc a
left join student d
on a.sid=d.sid
inner join sc b
on a.sid=b.sid and a.cid='01' and b.cid='02'
where a.score>b.score;
知識漏洞:還是一個(gè)表的自連接
進(jìn)階部分:
此部分選做,完成上面部分即可,如果完成也一起計(jì)分
查詢存在"01"課程但可能不存在"02"課程的情況(不存在時(shí)顯示為 null ) (10分)
查詢不存在"01"課程但存在"02"課程的情況(10分)
python:
基礎(chǔ)檢測部分:
- 定義一個(gè)列表:
array = [‘d’,’a’,’t’,’a’,’_’’f’,’r’,’o’,’g’],請使用空白字符把內(nèi)容都拼接起來(列表 join 的用法)(20分)
(沒看懂題目是要打印出來的意思)
array = ['d','a','t','a','_','f','r','o','g']
print(" ".join(array))
- 定義一個(gè)字典:
dict = {"english":60,"math":80,"music":100} ,請遍歷字典按照 “englist的分?jǐn)?shù)為:60” 的方式打印各科成績(字典屬性 items 的用法)(20分)
不會
dict = {"english":60,"math":80,"music":100}
for key,value in dict.items():
print("%s的分?jǐn)?shù)是:%s"%(key,value))
- 求1-100 的累加和(while循環(huán))(20分)
total=0
i=1
while i <=100:
total+=i
i+=1
print(total)
- 輸出【1,100】 之間的偶數(shù)(for循環(huán)判斷)(20分)
太久沒用了都忘了余數(shù)用%,好難過都不敢說自己學(xué)過python了
for i in range(1,101):
if i%2!=1 :
print(i)
- 定義一個(gè)計(jì)算面積的 area 函數(shù),函數(shù)有 width、height 長寬兩個(gè)參數(shù),使得傳入長寬就可以打印出面積(函數(shù)的定義)(20分)
def area(width,height):
return width*height
area(3,2)
進(jìn)階部分:此部分選做,完成上面部分即可,如果完成也一起計(jì)分
- 打印出所有的”水仙花數(shù)”,所謂”水仙花數(shù)”是指一個(gè)三位數(shù)(100-999),其各位數(shù)字立方和等于該數(shù)本身。例如:153是一個(gè)”水仙花數(shù)”,因?yàn)?53=1的三次方+5的三次方+3的三次方。(10分)
for i in range(100,999):
if i == int(str(i)[0])**3+int(str(i)[1])**3+int(str(i)[2])**3:
print(i)
- 請用面對對象的思想編寫一個(gè)小游戲,人狗大站,2個(gè)角色,人和狗,游戲開始后,生成2個(gè)人,3條狗,互相混戰(zhàn),人被狗咬了會掉血,狗被人打了也掉血,狗和人的攻擊力,具備的功能都不一樣。(定義 類+對象方法)(10分)
應(yīng)該算是開放題,但是我覺得條件太少直接放棄了
class People():
agressivity = 10
life_value = 100
def __init__(self,name):
self.name = name
def attack(self,dog):
dog.life_value -= 10
def __str__(self):
return '人%s剩余生命值:%s,狀態(tài)值%s'%(self.name,self.life_value,self.agressivity)
class Dogs():
agressivity = 15
life_value = 80
def __init__(self,name):
self.name = name
def attack(self,people):
people.life_value -= 10
def __str__(self):
return '狗%s剩余生命值:%s,狀態(tài)值%s'%(self.name,self.life_value,self.agressivity)
p1 = People('Tom')
p2 = People('Jack')
d1 = Dogs('niker')
d2 = Dogs('geeker')
d3 = Dogs('chaox')
print(p1)
print(p2)
p1.attack(d1)
print(d1)
手動題:
- pandas 讀取文件 order_info_utf.csv 保存到 mysql 庫中(使用 read_csv +to_sql 函數(shù))(10分)
mysql表結(jié)構(gòu)為:
CREATE TABLE `orderinfo` (
`orderid` int(11) NOT NULL,
`userid` int(11) DEFAULT NULL,
`isPaid` varchar(100) DEFAULT NULL,
`price` float DEFAULT NULL,
`paidTime` varchar(30) DEFAULT NULL)
放棄了因?yàn)橹纏ython怎么用pandas.read_csv(),但不會鏈接數(shù)據(jù)庫
知識漏洞:不會python鏈接數(shù)據(jù)庫
import pandas as pd
import sqlalchemy
engine=sqlalchemy.create_engine('mysql+pymysql://root:mysql@localhost:3306/data')
# 讀取數(shù)據(jù)
df=pd.read_csv('order_info_utf.csv',names=['orderid','userid','ispaid','price','paidtime'])
# 寫入數(shù)據(jù)到 mysql
# 還有參數(shù)if_exists,表示有則插入
df.to_sql('orderinfo',engine,index=False,if_exists='append')