Learning journal 1 PDF

Title Learning journal 1
Author Wasim Ismail
Course Introduction to Human Psychology
Institution University of the People
Pages 5
File Size 90.2 KB
File Type PDF
Total Downloads 49
Total Views 163

Summary

Learning journal 1...


Description

Part 1 1. If you are trying to print a string, what happens if you leave out one of the quotation marks, or both? Printing a string without one quotation mark will encounter a syntax error. While printing while not each quotation marks can print the worth because it is like for example: >>> print(123) The value will be printed the same as written in statement 123 2. You can use a minus sign to make a negative number like -2. What happens for each of the following? >>> 2++2 4 >>> 2--2 4 >>>2+-2 0 >>> 2-+2 0 3. In math notation, leading zeros are OK, as in 02. What happens if you try this in Python? >>> 02 File "", line 1 02 ^ SyntaxError: invalid token >>> print('02")

File "", line 1 print('02") ^ SyntaxError: EOL while scanning string literal >>> 2+02 File "", line 1 2+02 ^ SyntaxError: invalid token When we attempt to perform 02 in Python it offers the United States of America a syntax error: Invalid Token because it is against the rule or language of Python v3

4. What happens if you have two values with no operator between them? When we enter two values in python for example: print(2 2) without operators >>> print(2 2) File "", line 1 print(2 2) ^ SyntaxError: invalid syntax It gives us a syntax error: “invalid syntax” that is not compatible in Python language or against the language or rule of Python. Part 2 Describe at least three additional Python experiments that you tried while learning Chapter 1 1) Type of Value

>>> type(2)

>>> type(42.0)

>>> type('Hello, World!')

>>> A value is one in every one of the fundamental things a program works with, sort of a letter or variety. These values belong to completely different types: 2 is an associate whole number, 42.0 may be a number, and 'Hello, World! is a string, 2) The type of a value has changes if they are in quotation marks >>> type('2')

>>> type('42.0')

>>> They’re string types. 3)When you type a large integer, you might be tempted to use commas between groups of digits, as in 1,000,000. This is not a legal whole number in Python, however, it's legal: >>> 1,000,000 (1, 0, 0) >>> 1,123,456,789 (1, 123, 456, 789)

If values are the same 000, it will become 0

>>> >>> 1,222,333 (1, 222, 333) >>>...


Similar Free PDFs