Filters

Other

D

Your name is required for this document. It is only stored on this local computer and no where else. Please enter your name below:

National 5 Computing Science Practice Programming Tasks 1

Knox badge
National 5 Computing Science Practice Programming Tasks 1

Input and output

Program 1

Write a program to take in two numbers and display the result of them being added together.

Python
    print(int(input("Insert number 1")) + int(input("Insert number 2")))
    

Program 2

Write a program to take in a users name and then display "Hello " and the person's name.

Python
    print("Hello", input("Please insert your name"))
    

Variables and data types

Program 3

Adapt the program in Program 2 so that it now stores the user's name in a variable.

Python
    name = input("Please insert your name")
    print("Hello", name)
    

Program 4

Fix this program to ensure that it runs correctly.

Python
    var-1 = 1
    2ndvar = 2
    Β£var3 = 3
    class = 4
    
Python
    # Cannot have - in the name of the variable
    var1 = 1
    # Cannot have start a variable name with a number
    var2 = 2
    # Cannot have Β£ in the name of the variable
    var3 = 3
    # class is a keyword and cannot be used
    classVar = 4
    

Selection

Program 5

Write a program to take in two numbers, number1 and number2. If the first number typed in is larger than the second number it should add both numbers together. If the second number is larger, it should take the first number away from the second. If both numbers are equal it will multiple both numbers together. It should then display the result.

Python
    number1 = int(input("Please number 1"))
    number2 = int(input("Please number 2"))
    result = 0
    if(number1 > number2):
      result = number1 + number2
    elif(number2 > number1):
      result = number2 - number1
    else:
      result = number1 * number2
    print(result)
    

Program 6

Write a program to ask the user for a user name and password. The program should check that the user has typed in the correct password. If they have the program should display "Welcome to the system." otherwise it should display "Your details are incorrect and you cannot be logged in.".

Python
    username = input("Please enter a username")
    password = input("Please enter a password")
    if(username == "johnsmith" and password == "pass"):
      print("Welcome to the system.")
    else:
      print("Your details are incorrect and you cannot be logged in.")
    

Fixed loops

Program 7

Write a program to display all numbers from the two times table up to 2006.

Python
    for counter in range(1003):
      print(counter * 2)
    

Program 8

Write a program to take in 5 numbers and add them all together.

Python
    for counter in range(5):
      number = int(input("Enter a number"))
      total = total + number
    print(total)
    

Conditional loops

Program 9

Write a program to loop until the user types in a number that is greater than 100.

Python
  number = int(input("Enter a number over 100"))
  while number < 101:
    number = int(input("The number you entered is less than 100. Enter a number over 100"))
  print(total)
    

Program 10

Write a program which requires the user to login. The user must enter both a username and password which both need to be correct for the user to login.

Python
  username = input("Enter your username")
  password = input("Enter your password")
  while username != "username" or password != "password":
    print("Either your username or password (or both) was wrong.")
    username = input("Enter your username")
    password = input("Enter your password")
  print("Welcome!")
    

Reordering the code

Running total

Input validation

!
-- DragonDocs version 0.9 --

20.08.2017

Started on DragonDocs
Created a YASS/PHP and HTML-based system for saving and retrieving data

21.08.2017
Added CSS styles to page
Added JavaScript code to the page

02.02.2018
Added the multipage option (used in my dissertation)
Added the XMLHttpRequest-based multipage requests

08.02.2018
Added the Accessibility features
Filters added

10.02.2018
Purple filter added

17.03.2018
Added the Note class
Added the Did You Know class

-- DragonDocs version 1.0 (Yosemite) --

02.10.2019
First trial of DragonDocs in teaching

04.10.2019
Added the Task, Starter, Review your learning sections

07.10.2019
Added the feedback feature
Added the Dark Mode toggle

19.09.2020
Performance gains through the removal of unnecessary code
Added the Learning Intentions and Success Criteria features
Added the school badge

31.09.2021
Changed the headings (h2) to be more consistent with my website
Added sections to the pages - sections must be preceded by a h2
Added the "I have read this section" buttons
Changed the main heading zone to gradient text like my website
Added the table of contents feature

02.02.2022
Added the Print feature
Updated the footer to feature a new gradient
Added the Test It! class
Added the green flag
Automated the table of contents using JavaScript

06.02.2022
Added the 'includes' feature to the document, allowing inclusion of other files easily
Removed the requirement that the IP address must be one of the schools I have taught at, opening these documents to the public

02.03.2022
Once a section has been read or completed, the user can now hide that section

10.10.2022
Added the Extension task class
Changed the scrollbar on Windows to match that of macOS

-- DragonDocs version 2.0 (Kilimanjaro) --

07.08.2023
Added the Save button and the ability to save 'results' or answers to a Word document

12.01.2024
Added the large numbers class
Removed the background of the page navigation

-- DragonDocs version 2.1 (Aurora) --

08.02.2024
Added the active class to active links in the bottom section

09.02.2024
Added the image upload feature

10.02.2024
Added a fix that prevents the upload of non-image files into an image upload
Added pasting images to the upload feature

11.02.2024
Added the ability to view the changelog from a document
Improved the feedback system by recording the DragonDocs User ID and the Document ID data
The feedback from DragonDocs can be accessed much easier

12.02.2024
Added the new step_by_step_mode feature, allowing sections to be viewed individually
Added the ability to lock and unlock DragonDocs

22.02.2024
Added new checkboxes to each list item in a .task or .step
Added functionality to said checkboxes to add a strikeout to steps completed

23.02.2024
Added the new 'step' class
Steps are now auto incremented in CSS so the name displays the step number
Activities are now also auto incremented to display the activity number

25.02.2024
Added the 'matcher' feature to DragonDocs
Fixed an issue in which a closed section would retain it's original height within the document navigation
Added starters and the lesson review to the navigation on the side
The learning intentions and success criteria in teaching documents have now been redesigned to match my slides design

26.02.2024
All buttons are now on the right hand side
The accessibility button now has WAI under it

-- DragonDocs version 2.2 (Serengeti) --

26.02.2024
Code has been rewritten from the ground up to be object-oriented, making additional features easier to add

28.08.2024
Changed the look of grouped multiple choice buttons

06.03.2024
Added the new dragondocs_name feature and the requires_name property which allows names to be prepended to saved documents

09.03.2024
Added code so when the user types in their name and hits the enter key it will save that data and close the modal window
Added the new DragonShow and DragonDocs Link - a connection between both services that allows the presenter to communicate with users of DragonDocs from a DragonShow
Added the new timer option which is sent from DragonShows

04.04.2024
The matcher feature is no longer embed from jamiebalfour.scot but actually a feature of DragonDocs
Made DragonDocs 100% object-oriented, meaning much better management and better performance

05.04.2024
Made subtle changes to the interface to tidy it up a bit

06.04.2024
The multiple choice questions are now also part of the object oriented interface

09.04.2024
As requested, h3 elements are now included in the 'floating navigation'
The active navigation element now becomes bold and the left border has been retired

Time left

: