Skip to content

Instantly share code, notes, and snippets.

@balu
Last active January 13, 2021 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balu/7d444d5ce2d2126bc7976aa8aa4aae81 to your computer and use it in GitHub Desktop.
Save balu/7d444d5ce2d2126bc7976aa8aa4aae81 to your computer and use it in GitHub Desktop.
Homework related to names.
  1. What gets printed?
x = 1
y = 2
x = y
y = 3
print(x)
print(y)
  1. What gets printed?
x = 1
x = x + x
x = x * x
print(x)
  1. What gets printed?
name = 3
name = "foo" * name
print(name)
  1. Python allows names to contain letters, numbers, and underscore. Some examples of valid names are pi, area51, and area_of_circle. The underscore is usually used to separate different words in a name. Why doesn't python allow hyphens in names? For example, area-of-circle is an invalid name in python. What could be the reason for this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment