Saturday, 20 June 2020

Introduction to Computer Science and Programming Using Python

thank you prof

length of string

# Make sure to un-comment the function line below when you are done.
# Remember to name your function correctly.
# WRITE YOUR CODE HERE...

def string_length(str1):
  return len(str1)

# DO NOT remove lines below here,
# this is designed to test your code.

def test_string_length():
  assert string_length('hello!') == 6
  assert string_length('banana') == 6
  assert string_length('8') == 1
  assert string_length('funnyguys') == 9
  assert string_length('101') == 3
  print("YOUR CODE IS CORRECT!")

# test your code by un-commenting the line(s) below
test_string_length()


Introduction to Computer Science and Programming Using Python | Python Basics | Introduction




last_letter

# Make sure to un-comment the function line below when you are done.
# Remember to name your function correctly.
# WRITE YOUR CODE HERE...

def last_letter(str1):
  return str1[len(str1)-1]

# DO NOT remove lines below here,
# this is designed to test your code.

def test_last_letter():
  assert last_letter('hello!') == '!'
  assert last_letter('banana') == 'a'
  assert last_letter('8') == '8'
  assert last_letter('funnyguys') == 's'
  assert last_letter('101') == '1'
  print("YOUR CODE IS CORRECT!")

# test your code by un-commenting the line(s) below

 test_last_letter()


======
great job to me
from 61% this morning to 85% and i am sleepy
so good night to all..

85% COMPLETE



No comments: