Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AI Progamming Exercises
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Mutote
AI Progamming Exercises
Commits
14e7dc4f
Commit
14e7dc4f
authored
1 year ago
by
Michael Mutote
Browse files
Options
Downloads
Patches
Plain Diff
22202956
answer 4 was incorrect. removed it. Question 5 done.
parent
57eeaec6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
2.7 Exercises.py
+10
-2
10 additions, 2 deletions
2.7 Exercises.py
with
10 additions
and
2 deletions
2.7 Exercises.py
+
10
−
2
View file @
14e7dc4f
# question 1
def
rotateR
(
val
):
return
val
[
-
1
]
+
val
[
1
:
len
(
val
)
-
1
]
+
val
[
0
]
return
val
[
-
1
]
+
val
[
1
:
len
(
val
)
]
if
len
(
val
)
>
0
else
None
...
...
@@ -12,8 +12,16 @@ def rotateR(val):
# question 4
def
rotateRx
(
val
):
val
[
0
],
val
[
-
1
]
=
val
[
-
1
],
val
[
0
]
pass
# question 5
def
rotateRx_modified
(
val
):
# cannot be modified to work for strings, without returning a value. Python strings are immutable. They cannot be
# modified once they are created:
# ```TypeError: 'str' object does not support item assignment```
# So the only way to achieve this would be to return a value and assign it back.
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment