csc 131 introduction to computer science i n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
CSC 131 - Introduction to Computer Science I PowerPoint Presentation
Download Presentation
CSC 131 - Introduction to Computer Science I

Loading in 2 Seconds...

play fullscreen
1 / 11

CSC 131 - Introduction to Computer Science I - PowerPoint PPT Presentation


  • 110 Views
  • Uploaded on

CSC 131 - Introduction to Computer Science I. Review Question for test 3. Devon M. Simmonds Computer Science Department University of North Carolina Wilmington Wilmington, NC 28403 simmondsd@uncw.edu http://www.uncw.edu/people/simmondsd/

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CSC 131 - Introduction to Computer Science I' - kamil


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
csc 131 introduction to computer science i

CSC 131 - Introduction to Computer Science I

Review Question for test 3

Devon M. Simmonds

Computer Science Department

University of North Carolina Wilmington

Wilmington, NC 28403

simmondsd@uncw.edu

http://www.uncw.edu/people/simmondsd/

_____________________________________________________________

..

strings
Strings
  • Answer the following questions. Where an error occurs, state how the error can be fixed.
  •  Assume: ch = “TEST”, ch1 = “A”, num1 = 7
  • What does this code produce: print(chr(Ord(ch1)))
  • Which of the following is not an escape sequence:
    • \\
    • \t
    • \r
    • \p
    • None of the above
strings1
Strings
  •  Assume:

num1 = 7

five = '5'

  • What does this code produce: print("There are " + num1 + " days in a week")
  • What does this code produce: print("I am multiplying 5 by 7 to get: ", five * num1)
  • What does this code produce:
    • num = input("Enter two numbers").split()
    • #The user enters: 1.5 4.0
    • print(num[0] * num[1])
strings2
Strings
  • What does this code produce:
  • a = "1234"
  • b = "4cats"
  • c = 12345
  • x = "123".isdigit()
  • print(x)
  • y = a.isdigit()
  • print(y)
  • z = b.isdigit()
  • print(z)
  • w = c.isdigit()
  • print(w)
strings3
Strings
  • 1. What does this code produce:
  • print("JohnGov".isalpha())
  • print("John Gov".isalpha())
  • print("John4Gov".isalpha())
  • 2. What does this code produce:
  • x = "In the beginning God created the heavens and the earth."
  • print(x.startswith ("In the beginning"))
  • print(x.startswith ("in"))
  • print(x.endswith ("Earth"))
  • 3. What does this code produce:
  • print("To be or not to be".replace("be", "was"))
  • print("To be or not to be".replace("be", "was", 1))
strings4
Strings
  • 1. What does this code produce:
  • x = "In the beginning God created the heavens and the earth."
  • print(x.find ("In the beginning"))
  • print(x.find ("in"))
  • print(x.find ("Earth"))
  • 2. What does this code produce:
  • x = "In the beginning God created the heavens and the earth. And the earth was …"
  • print(x.rfind ("In the beginning"))
  • print(x.rfind ("in"))
  • print(x.rfind ("earth"))
  • 3. What does this code produce:
  • x = "In the beginning God created the heavens and the earth."
  • print(x.count ("In the beginning"))
  • print(x.count ("in"))
  • print(x.count ("earth"))
lists
Lists
  • Write code to show four different ways to create a list of ten values.
  • Write code to search the list numbers for the value of variable x and the print a message indicating found or not found.
  • What does this code produce:

x = [1,3,2,3,4,5,4,6,7,8,9]

x.insert(2, 44)

print(x)

x.remove(4)

print(x)

print(x.pop(1), "---", x)

print("To be or not to be, or not to be to be.".split("to"))

lists1
Lists
  • Other topics
  • List slicing
  •  Copying lists
lists2
Lists
  • Default arguments: How do these two functions differ?

def add(x, lst = []):

if not(x in lst):

lst.append(x)

return lst

def add(x, lst= None):

if(lst == None):

lst = []

if not(x in lst):

lst.append(x)

return lst

files
Files
  • How these functions work
    • open close, read, readline, readlines, write
the end

Qu

es

ti

ons?

The End

______________________

Devon M. Simmonds

Computer Science Department

University of North Carolina Wilmington

_____________________________________________________________