0% found this document useful (0 votes)
9 views

10Co6 Cover Work

The document outlines a series of Python programming exercises focused on data types, operators, selection, iteration, lists, and strings. Each section includes specific tasks such as creating variables, using arithmetic operators, writing loops, and manipulating lists. Additionally, it provides hints and links to resources for further learning.

Uploaded by

aryashah4879
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

10Co6 Cover Work

The document outlines a series of Python programming exercises focused on data types, operators, selection, iteration, lists, and strings. Each section includes specific tasks such as creating variables, using arithmetic operators, writing loops, and manipulating lists. Additionally, it provides hints and links to resources for further learning.

Uploaded by

aryashah4879
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

10Co6 Cover Work

1.0. Data Types and Operators


1.1. Write a python program which displays the line: “Gorillas are the largest living
primates” and on the next line “Gorilla gorilla gorilla” with one print statement
making use of “\n” in the output.

1.2. Get an input from the user, save it as a variable called “name” and then output the
lines 1.1. but replace gorilla with the name the user has input hint you can use
print(“Gorillas are the largest living primates\n”, name) – see what impact this has

1.3. Create an integer, real/float, char/character, string and Boolean variables

1.4. Make use of all the following arithmetic operators: Addition, Subtraction,
Multiplication, Division and Exponentiation. Hint:
https://www.w3schools.com/python/gloss_python_arithmetic_operators.asp
2.0. Selection
2.1. Code a Boolean expression that asks if 10 times 7 is equal to 70 and then prints
success if that is true. Hint:
https://www.w3schools.com/python/gloss_python_if_statement.asp

2.2. What will be printed for the following:


A = 24/8
B = 24+8
Print(A==B)

FALSE

2.3. Change the code in 2.2. to make it print True instead

Insert Screenshot of code and solution working here

2.4. Print((10 == 5 *2) and (45 != 9 * 5)) will display what and explain why

Insert Screenshot of code and solution working here


FALSE as 9*5 does equal 45 so one of the off the solution is false. A TRUE and FALSE OUTPUT
FALSE
3.0. Iteration
Guides to Iteration:
https://www.w3schools.com/python/python_iterators.asp

3.1. Write a program for an arcade game which will print “You win!” 3 times and then
print “Congratulations!” using a for loop

Insert Screenshot of code and solution working here

3.2. Write a program to count down from 10 to 0 and display each value on a separate
line

Insert Screenshot of code and solution working here

3.3. Write a program which will ask the user which times table they would like to see
displayed. Then get the users and number and show 2 to 12 times table for that
number

Insert Screenshot of code and solution working here

3.4. Write a program to ask the user to input two positive integers a and b where a < b.
Print all numbers between a and b inclusive that are divisible by 13

Insert Screenshot of code and solution working here


3.5. Write a program to count numbers from 0 to 100 in 5s and print them all on one
line. Tip include the parameter end = “” in print statements e.g. print(n, end = “”) to
prevent going to a new line after executing a print statement

Insert Screenshot of code and solution working here

3.6. Write a program to:


 Allow a user to enter the names and years of five Olympic Games cities
 Calculate and print the names and years of the two cities with the most
recent and earliest years

Insert Screenshot of code and solution working here


4.0. List
https://www.w3schools.com/python/python_lists.asp
4.1. Write a program to create a list of planets – add every planet in our solar system
then print these out using iteration

Insert Screenshot of code and solution working here

4.2. Use list.append() to add more planets from other solar systems and print the
updated list

Insert Screenshot of code and solution working here

4.3. Write a program to ask the user to enter the number of astronauts sent on space
missions in the years 2016 to 2020 e.g. “How many astronauts on space missions in
2016?”
Store the numbers in a list named astronauts (each year being own element)
Print the list and the total number of astronauts sent on space missions from 2016
to 2020.

Insert Screenshot of code and solution working here

4.4. Write a statement to initialise a list named totals containing 100 zeros. Hint you can
make a list of 7 zeros by doing the following:
“mylist = [0]*7”

Insert Screenshot of code and solution working here


4.5. Write a program which creates two lists each with 6 elements:
 One list stores the name of planets
 Second list stores the size of the planets relative to Earth
 Then use a for loop (iteration) to output both e.g. “Jupiter 1120% size of
Earth”

Insert Screenshot of code and solution working here

More list exercises:

https://www.w3schools.com/python/exercise.asp?filename=exercise_lists1
5.0. Strings
https://www.w3schools.com/python/python_strings.asp
5.1. Run the following code and explain using comments in the code what is happening:
numChars = len(“5 Oak Street Anytown”)
print(numChars)

Insert Screenshot of code and solution working here

5.2. Run the following code and explain using comments in the code what is happening:
Print(len(“Mary\nJo”))

Insert Screenshot of code and solution working here

5.3. Create a program that asks the user to enter their name and then prints the number
of characters in their name and the first and last characters

Insert Screenshot of code and solution working here

5.4. Write a program to ask the user to enter a sentence. Calculate and print the number
of times the letter “e” appears in the sentence

Insert Screenshot of code and solution working here


5.5. Using the techniques used above: Write a program that asks the user to enter a new
password. The password must be at least 10 characters long and the user is
repeatedly asked to re-enter a password if it is less than 10 characters (iteration).
Once the user has entered a valid password, the user is asked to verify it by entering
it a second time. If it matches, the message “Password accepted” is printed.
Otherwise an error message is printed and the program terminates.
Hint: https://www.w3schools.com/python/python_strings_methods.asp

Insert Screenshot of code and solution working here

Extra String Exercises:

5.6. https://www.w3schools.com/python/python_strings_exercises.asp

You might also like