Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Java (2) — CSCI 134: Introduction to Computer Science CSCI 134: Introduction to Computer Science Calendar Syllabus Office and TA Hours Resources Programmer’s Toolbox Python Quick References Strings and Lists Viewing Feedback on Labs Python Style Guide Set Up Your Computer For CS 134 Set Up Your Mac Set Up Your Windows PC Set Up Your Windows PC (Non-Linux Version) How To Use Jupyter Notebooks Useful Links Think Python Textbook Computer Science Department Williams College Contents Java (2) Strings in Python Lists in Python Dictionaries in Python Conditional Statements Java (2) Contents Java (2) Strings in Python Lists in Python Dictionaries in Python Conditional Statements Java (2)¶ Here we look at common Python operations. Strings in Python¶ Now let’s look at some common String operations in Python. s = "Almost summer break" s[:3] 'Alm' s[4:7] 'st ' s.upper() 'ALMOST SUMMER BREAK' s.lower() 'almost summer break' array = s.split() print(array) ['Almost', 'summer', 'break'] Lists in Python¶ alist = [] alist.append("Jeannie") alist.append("Rohit") alist.append("Lida") alist.append("Steve") alist.append("Dan") alist.append("Sam") print(alist) ['Jeannie', 'Rohit', 'Lida', 'Steve', 'Dan', 'Sam'] alist.insert(3, "Iris") print(alist) ['Jeannie', 'Rohit', 'Lida', 'Iris', 'Steve', 'Dan', 'Sam'] alist[2] 'Lida' alist[5] = "Steve" print(alist) ['Jeannie', 'Rohit', 'Lida', 'Iris', 'Steve', 'Steve', 'Sam'] Dictionaries in Python¶ csCourses = dict() csCourses[237] = "Computer Organization" csCourses[134] = "Intro to Computer Science" csCourses[136] = "Data Structures" csCourses[256] = "Algorithms" csCourses[237] 'Computer Organization' csCourses.get(134) 'Intro to Computer Science' 134 in csCourses True 361 in csCourses.keys() False "Data Structures" in csCourses.values() True Conditional Statements¶ a = 1 b = 2 if a < b: print("a < b") a < b if a > b: print("a > b") else: print("a < b") a < b c = 3 if a > b and a > c: print("a is largest") elif b > a and b > c: print("b is largest") else: print("c is largest") c is largest © Copyright 2022.