第四次作业

本文通过Python代码示例介绍了条件语句的使用方法,并展示了如何操作字符串、列表及字典等数据结构。文章包括字符串比较、条件判断、循环遍历等基本语法的应用场景。

5-2

s1='aabbcc'
s2='AAbbcc'
if s1==s2:
	print('s1==s2')
	print(s1==s2)
else:
	print('s1!=s2')
	print(s1==s2)
if s1.lower()==s2.lower():
	print('True')
if 3>2:
	print('3>2')
if 4<=5:
	print('4<=3')
if 5==5:
	print('5==5')
if 2<4:
	print('2<4')
if 6>=5:
	print('6>=5')

if 2<4 and 6>=5:
	print('2<4 and 6>=5')
if 2<4 or 1>5:
	print('2<4 or 1>5')
array=['a','b','c']
if 'a' in array:
	print('a is in array')
if 'd' not in array:
	print('d is not in array')
	


5-3

alien_color='green'
if alien_color=='green':
	print('the alien color is '+alien_color+' the player get 5 points')
alien_color='yellow'
if alien_color=='green':
	print('the alien color is '+alien_color+' the player get 5 points')


5-10

current_users=['Sam','Amy','Tom','Mike','Carol']
new_users=['Sam','Amy','Cindy','Perse','Lake']
for new_user in new_users:
	if new_user in current_users:
		print(new_user+' has been used')
	else:
		print(new_user+' has not been used')


6-1

acquaintance_info={
    'first_name': 'John',
	'last_name': 'Smith',
	'age': '30',
	'city': 'New York',
    }
print(acquaintance_info['first_name'])
print(acquaintance_info['last_name'])
print(acquaintance_info['age'])
print(acquaintance_info['city'])


6-5

rivers={
    'nile': 'egypt',
    'yangtz': 'china',
    'huanghe': 'china',
    'mississippi': 'america',
    'volga': 'russia',
    }
for river,country in rivers.items():
	print(river +" flows over "+country)
for river in set(rivers.keys()):
	print(river)
for country in set(rivers.values()):
	print(country)


6-8

pets=[]
for n in range(5):
	new_pet={str(n): str(n+1), str(n+2): str(n+3)}
	pets.append(new_pet)
for pet in pets:
	print(pet)

6-9

p1=['a','b','c']
p2=['aa','bb','cc']
p3=['aaa','bbb','ccc']
favorite_place={
    'Tom': p1,
    'Mike': p2,
    'Amy': p3,
    }
for name,place in favorite_place.items():
	print("\n"+name+" favorite place: ")
	print(place)

6-11

c1={
    'country':"china",
    'population':"1000",
    'fact':'x',
    }
c2={
    'country':'america',
    'population':'1001',
    'fact':'y',
    }
c3={
    'country':'australia',
    'population':'1002',
    'fact':'z',
    }
cities={
    'c1':c1,
    'c2':c2,
    'c3':c3,
    }
for city,info in cities.items():
	print("\n"+city+":")
	print(info)

【有功-无功协调优化】基于改进多目标粒子群优化算法(小生境粒子群算法)的配电网有功-无功协调优化研究(Matlab代码实现)内容概要:本文围绕“基于改进多目标粒子群优化算法(小生境粒子群算法)的配电网有功-无功协调优化研究”展开,重点介绍了利用小生境粒子群算法对配电网中的有功与无功功率进行协调优化的方法。研究结合Matlab代码实现,旨在降低网络损耗、提升电压质量,并增强配电网运行的经济性与稳定性。文中详细阐述了改进多目标粒子群算法的设计思路,包括引入小生境机制以增强种群多样性、避免早熟收敛,同时构建了综合考虑有功出力调节、无功补偿装置投切及分布式电源协同控制的优化模型。通过在标准测试系统(如IEEE33节点系统)上的仿真验证,展示了该方法在多目标优化中的有效性与实用性。; 适合人群:具备电力系统基础知识和Matlab编程能力,从事电力系统优化、智能算法应用及相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于含分布式电源的主动配电网运行优化;②解决多目标环境下有功与无功资源的协同调度问题;③为配电网节能降损、电压调控提供算法支持与仿真验证手段; 阅读建议:建议结合提供的Matlab代码进行仿真实践,重点关注算法参数设置、适应度函数设计及多目标解集的Pareto前沿分析,同时可扩展至不同网络结构与运行场景以加深理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值